2019/4/25
private int ySpeed = 0; public void act() { if (ySpeed == 0 && Greenfoot.isKeyDown("enter")) ySpeed = 1; // start setLocation(getX(), getY()+ySpeed); // move if (isTouching(Actor.class)) setLocation(getX(), getY()-ySpeed); // stop (negates move) }
X