When I select my first door, sometimes it reveals the door with the prize behind it. How do I get it to not reveal the prize on the first click of the mouse?
From ggc
If you have an instance variable for where the prize is, you can do this with an if statement. In your instance variable declarations, suppose you have
private int prizeDoor;
and somewhere in your startGame method, you have a statement like:
prizeDoor=random.nextInt(3)+1;
then in your advanceFrame you can make sure not to open the prize door by checking the value of prizeDoor:
if(door1.intersects(click))
{
if(prizeDoor!=1)
{
canvas.removeSprite(door1);
}
}
This way when the player clicks on door1 it only is opened if it is not the prize door. See if this example helps you do what you want to do.
- This page was last modified on 31 January 2008, at 15:09.
- This page has been accessed 194 times.
- Privacy policy
- About ggc
- Disclaimers
- Powered by MediaWiki!









