G'day. my actor jumps perfectly, however when i jump to high platforms, and fall down, it doesn't land on the platform, below, instead, it goes right down to the bottom of the world. can anyone help me please?
^^This is my code^^
public class Frog extends Actor
{
private int speed = 2; //movement speed
private int vSpeed = 0; //vertical speed
private int acceleration = 2; //gravity effect while falling
private int jumpStrength = -20;
public void act()
{
checkKeys();
checkFall();
jump();
}
private void checkKeys()
if(Greenfoot. isKeyDown("space"))
{
jump();
}
}
public void jump()
{
if (Greenfoot.isKeyDown("space") && onPlatform())
{
vSpeed = jumpStrength;
fall();
}
}
public void fall()
{
setLocation(getX(), getY()+vSpeed);
vSpeed = vSpeed + acceleration;
}
public boolean onPlatform()
{
Actor under = getOneObjectAtOffset (0, getImage().getHeight()/2, Platform.class);
return under != null;
}
public void checkFall()
{
if (onPlatform())
{
vSpeed = 0;
}
else
{
fall();
}
}
}

