sum = 0;
jumpStrength = 16;
while(jumpStrength >= sum)
{
setLocation(getX(), getY() - sum);
Greenfoot.delay(1);
sum= sum+1;
}
fall(); // after reaching the jumping height ie jumpStrenght, actor falls.
im doing a doodle jump game. So there are platforms and platforms keep on moving from the top to bottom.
the jumping actor is a frog. when i press space --> "jumping button", the platforms hangs ie it stop moving down till the frog makes the jump ie till the while loop is executed ie the following code in platform stops working.
public class platform extends Actor
{
public void act()
{
move(2);
if(getY() > 580) // height of the world is 600. so once it reaches down the platform is removed.
{
getWorld().removeObject(this);
return;
}
}
}