I have a game called 'Infinity' and I want infinity to have an achievement. When the user gets to the 10th pipe then stop the game, and present a dialog. I've tried this:
Bird Class:
Sky (game) code
thanks!
public void act() {
// Checks if the bird flaps.
checkFlap();
// Moves the bird.
move();
// Checks if the bird hits the obstacles.
if (checkHit()) {
Sky sky = (Sky) getWorld();
sky.gameOver(score);
} else {
// Checks if the bird gets ths score.
checkScore();
}
Sky sky = new Sky();
AchievementOne achievementOne = new AchievementOne();
if(this.intersects(achievementOne)){
sky.adddies();
sky.ahievement();
System.out.println("pass");
}
} int dies = 0;
Boolean menue=false;
/**
* Constructor for objects of class Sky.
*
*/
public Sky() {
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
addObject(new Bird(), getWidth() / 2, getHeight() / 2);
scoreBoard = new ScoreBoard();
addObject(scoreBoard, 70, 50);
pipeTimer = PIPE_INTERVAL * 2;
setPaintOrder(GameOver.class, ScoreBoard.class, Bird.class, Pipe.class);
Greenfoot.playSound("sounds/background.mp3");
}
//The 2 blocks of code are for the 'Die after 10 pillars' achievement.
public void adddies()
{
dies++;
}
public void ahievement()
{
if(dies>2&&menue==true)
{
addObject(new AchievementOne(),100,100);
}
}
/**
* Things to do for each turn.
*
*/
public void act() {
// Adds a pipe pair periodically.
addPipePairPeriodically();
Greenfoot.setSpeed(40);
adddies();
ahievement();
}
/**

