Hi.
I'm working on a game which requires the player to click on a moving dot within a certain time period. There are multiple levels, and for each level, another dot appears that you must click. To progress, I want it to be that you click all the dots, but once it's been clicked, it disappears.
Basically, I need to know the code which gives the game the intelligence to only change levels once both the dots have been clicked.
This is my code so far:
(Thanks to danpost for the help! (Click here to see))
The current class (dotA) is green and after a certain time, it changes to another class (dotA2), and then an A3. The code for the transition can be seen in the method click().
Any ideas would be much appreciated.
Thanks.
private int timer = 5;
public void act()
{
move();
click();
if (timer > 0)
{
timer --;
if (timer == 0)
{
timer = 5;
getWorld().addObject(new dotA2(), 127, 286);
getWorld().removeObject(this);
}
}
}
public void move()
{
setLocation(Greenfoot.getRandomNumber(600), getY());
setLocation(getX(), getY() + Greenfoot.getRandomNumber(400));
setLocation(getX(), getY() - Greenfoot.getRandomNumber(400));
Greenfoot.delay(60);
}
public void click()
{
if (Greenfoot.mouseClicked(this))
{
getWorld().removeObject(this);
Greenfoot.setWorld((new dotWorld3()));
}
}
