I want to add 1 to the score counter when my character jumps over an obstacle. But I don't know what the condition will be. please help me!!!
Here is the code for my obstacle:
public class Obstable2 extends Actor
{
int moveSpeed=3;
public void act()
{
setLocation (getX()-moveSpeed, getY());
remove();
spawn();
}
private void remove()
{
Actor position= getOneIntersectingObject(Frog.class);
if (position !=null)
{
World world;
world=getWorld();
GameOver game = new GameOver();
world.addObject(game, world.getWidth()/2, world.getHeight()/2);
world.removeObject(position);
}
}
private void spawn()
{
int heightOfObstable2 =getImage().getHeight();
Actor theblock=getOneObjectAtOffset(599, 600, Obstable2.class);
}
}
Here is the code for my world:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class brick extends World
{
Counter counter = new Counter();
public brick()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1000, 599, 1, false);
Frog position= new Frog();
addObject(position, 50,420);
Stage pos = new Stage();
addObject(pos, 500,525);
Obstable2 jump2= new Obstable2();
addObject(jump2, 1050, 420);
addObject(counter, 100, 40);
}
private int spawnCounter = 0;
public void act() {
if (spawnCounter > 100) {
spawnCounter = 0;
addObject(new Obstable2(), Greenfoot.getRandomNumber(1050)+1050,420);
}
spawnCounter++;
}
public Counter getCounter()
{
return counter;
}
}

