import com.genuts.gameui.*; /** * Moves a sprite from the left to the right, and change the * direction when a sprite with an id of 0 is encountered. */ public class TileWrapper extends MovingSpriteWrapper { int vx = 1; public TileWrapper(Sprite sprite) { super(sprite); } public void move(int ticks) { getActionSprite().setPosition(getX()+vx, getY()); } protected void collisionWith(Sprite s) { // Checks the id of the sprite to know if the direction // has to be changed or not. if ((s != null) && (s.getId() == 0)) { vx *= -1; getActionSprite().setPosition(getX()+2*vx, getY()); } } }