i am a beginner in java. i try to make a mini game with 2 classes: the menu and the play. i am trying to randomly change the image of an object in the play class by clicking a button in the menu class
So, in the menu class i add a button and add input listener so that when i click
play.level = MathUtils.random(1);
int the play class, i add static int level, an object
if(level == 0){object.draw(batch);) else`if(level == 1){object.draw(batch1);}
and input listener:
if (TocuhDown) {System.out.println ("" + level);}
when i run the program, the level value VARIES between 0 and 1 but the object always draw image batch. if i change the code in the menu class so that it only brings me to play class and the in play class i change the level to
public static int level = MathUtils.random(1);
my level value varies and the object randomly draws either batch image or batch1 image. However i want to do this from the menu class. and since the program runs and i cant think of the logic error, i am stuck now. can someone please tell me why i cant change my object image by clicking the button in the menu class?
0 comments:
Post a Comment