vendredi 18 septembre 2015

dysfunctional IF (program go on both opinion)

I have problem with these code ↓

I have game with button Play (if i start app) and button Try again (if player lose), but these code run only in Play button If I open activity from "Try again" I have problem with gifView in If Branch, so program run on both if branch. I test variables with Toast and...

I don't know where are error.

if (tut>3) {
    current_image_index = (int) (Math.random() * 12);
    potom.setImageResource(images[current_image_index]);
    if (dalej == -1) {                
    } else {
        savetotxt(STORETEXT6, dalej);
        gifView = (GifView) findViewById(R.id.gif_view);
        nabody = dalej;
        dalej = current_image_index;
    }
    if (score > highscore) {
        highscore = score;
    }
}
else {
    switch (tut) {
        case 0:
            savetotxt(STORETEXT6, 16);
            gifView = (GifView) findViewById(R.id.gif_view);
            potom.setImageResource(R.drawable.tutorial1);
            tut++;
            break;
        case 1:
            savetotxt(STORETEXT6, 13);
            gifView = (GifView) findViewById(R.id.gif_view);
            potom.setImageResource(R.drawable.tutorial2);
            nabody = 0;
            tut++;
            break;
        case 2:
            savetotxt(STORETEXT6, 14);
            gifView = (GifView) findViewById(R.id.gif_view);
            potom.setImageResource(R.drawable.tutorial3);
            nabody =5;
            tut++;
            break;
        case 3:
            savetotxt(STORETEXT6, 15);
            gifView = (GifView) findViewById(R.id.gif_view);
            current_image_index = (int) (Math.random() *12);
            dalej = current_image_index;
            potom.setImageResource(images[current_image_index]);
            nabody = 11;
            tut++;
            break;
        }
    }
    textView2.setText(Long.toString(highscore));
}

Description error. In GifView I see together

 savetotxt(STORETEXT6, 16);
 gifView = (GifView) findViewById(R.id.gif_view);

and

 savetotxt(STORETEXT6, dalej);
 gifView = (GifView) findViewById(R.id.gif_view);

In onCreate I have:

tut=0;

Please help me :)

Aucun commentaire:

Enregistrer un commentaire