This site requires JavaScript, please enable it in your browser!
Greenfoot back
Avik
Avik wrote ...

2013/5/18

Urgent

Avik Avik

2013/5/18

#
I have a scrolling background and I have placed my coins in it. After that scrolls, all the coins bunch tot the side if I don't get them, how do I fix this?
Gevater_Tod4711 Gevater_Tod4711

2013/5/18

#
You just have to remove all coins that reached the side.
if (getX() < 20) {//or getX() > getWorld().getWidth() - 20 if you want to delete the coins at the right side;
    getWorld().removeObject(this);
    return;
}
If you add this code to your coin class (into the act method) it should work.
Avik Avik

2013/5/18

#
I've dont that but I want the coins to repeat its self in the next world eg once the background has scrolled I want the same coins in the next time it scrolls.
Gevater_Tod4711 Gevater_Tod4711

2013/5/18

#
Then you should set the location of the coins to the other edge of the world:
if (getX() < 20) {
    setLocation(getWorld().getWidth()-20, getY());
}
You need to login to post a reply.