This site requires JavaScript, please enable it in your browser!
Greenfoot back
new113
new113 wrote ...

2017/1/15

Numbers being pressed in order

new113 new113

2017/1/15

#
So I am making a game but I have ran into a small bug/ problem. Basically when the buttons 3, 2, or 1 and are pressed in order the counter goes down on screen, but the problem is that when the buttons are pressed out of order they get all mixed up and such. In a nutshell I want the numbers on screen to count down from 3 and to stay at 0 and to stay in order so the player cannot just press the numbers(3, 2, 1) randomly. The code I have been using is, if (Greenfoot.isKeyDown("3")) { setImage(new GreenfootImage("2", 18, Color.WHITE, Color.GREEN)); }
Super_Hippo Super_Hippo

2017/1/15

#
You probably need a condition which image is currently active (you can also save an int). So only if the image is 3 and the button 3 is pressed, set the image to 2.
new113 new113

2017/1/16

#
Thanks for your help
You need to login to post a reply.