I want my actor to go up and down. I know I must use the if and whenkeyis up ect but after that what do i do? I have tried move and turn but it doesn't work. Should I be using a specific integer?


1 2 3 4 5 6 7 8 9 | int speed = 3 ; if (Greenfoot.isKeyDown( "up" )) setLocation(getX(), getY() - speed); if (Greenfoot.isKeyDown( "down" )) setLocation(getX(), getY() + speed); if (Greenfoot.isKeyDown( "left" )) setLocation(getX() - speed, getY()); if (Greenfoot.isKeyDown( "right" )) setLocation(getX() + speed, getY()); |