never mind works. However all stationary sprites are leaving thier images behind infinitely.


import greenfoot.*; public class Trex extends Actor { private int ySpeed; public Trex() { } public void setLoaction(int x, int y) {} public void act() { int groundLevel = 500 - getImage().getHeight()/2; boolean onGround = (getY() == groundLevel); if (!onGround) { ySpeed++; setLocation(getX(), getY()+ySpeed); if (getY()>=groundLevel) { setLocation(getX(), groundLevel); Greenfoot.getKey(); } } else // on ground { if ("up".equals(Greenfoot.getKey())) { ySpeed = -16; setLocation(getX(), getY()+ySpeed); } } if (Greenfoot.isKeyDown("down")) { setImage("duck.png"); } else { setImage("Trex.png"); } } }
... new Trex() ...