How do you get both doors to go away at the same time when you click the second time?
From ggc
Here's some sample code for making one door go away when clicked:
Point2D.Double click=getPlayer().getMouse().getClickLocation();
if(click!=null)
{
if(door1.intersects(click))
{
canvas.removeSprite(door2);
}
}
If instead you wanted two doors to go away, you'd do something like:
Point2D.Double click=getPlayer().getMouse().getClickLocation();
if(click!=null)
{
if(door1.intersects(click))
{
canvas.removeSprite(door2);
canvas.removeSprite(door3);
}
}
The basic idea is that you can put any number of statements in the code block following the if condition. In the case you want one thing to happen, just put one statement. In the case you want two things to happen, put 2 statements. If you want N things to happen, put N statements.
- This page was last modified on 31 January 2008, at 13:15.
- This page has been accessed 195 times.
- Privacy policy
- About ggc
- Disclaimers
- Powered by MediaWiki!









