Making a run and jump and all I need is for objects to spawn in the same position but move along and out of the screen. i need it to spawn from the right and leave from the left.
Pipe pipe = new Pipe();
addObject(pipe, 620, 300);
Pipe[] pipes = new Pipe[Greenfoot.getRandomNumber(getWidth())];
public void act()
{
setLocation(getX()-1, getY()); //change 1 to something higher for higher speed
if (getX()<1) getWorld().removeObject(this); //remove the object when it reached the left side
}private Pipe lastSpawned;
int minimumGap = 100; // adjust to suit
if (lastSpawned == null || lastSpawned.getX() < getWidth()-minimumGap+20)
{
if (Greenfoot.getRandomNumber(150) < 2)
{
lastSpawned = new Pipe();
addObject(lastSpawned, getWidth()+20, 300);
}
}