How do you get both doors to go away at the same time when you click the second time?

From ggc

Jump to: navigation, search

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.





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter