Hello! I am trying to create a scenario, where my actor is able to climb a ladder. However it doesn´t seem to work right, because when I press "up" my Actor starts to bounce just a bit on and off the Ground underneath. I am thinking, that it might be something in relation to my "JumpHeight". Here is my code for the Actor:
Its just the public void jump and of course I added it in my act method and got no syntax errors
public void jump()
{
if(Greenfoot.isKeyDown("space")&& (onGround()==true))
{
vSpeed = jumpHeight;
fall();
}
else if(isTouching(Ladder.class))
{
if(Greenfoot.isKeyDown("up"))
{
int ypos = getY();
ypos = ypos - 5;
setLocation(getX(), ypos);
}
}
}