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

2014/1/29

Save after running.

xnefoo xnefoo

2014/1/29

#
I am making a side scrolling platform game. But to make the world i need to place the blocks then run it so i can scroll over and make the world larger, then place more blocks. But after doing that I cannot save the world. Is there any way to work around this? Thanks
bourne bourne

2014/1/29

#
You might be able to do something like the following: Give your World a public method like
public void scrollAllObjects(int offsetX, int offsetY)
{
    for (Actor actor : (java.util.List<Actor>)getObjects(null))
        actor.setLocation(actor.getX() + offsetX, actor.getY() + offsetY);
}
Then you could place your blocks, right click on the World, invoke the above method to move everything over a given amount/direction, then place more blocks, and so on. And finally save your World. You might have Actors that shouldn't be scrolled, you could replace null with something like Block.class (if that is the name of your blocks class)
xnefoo xnefoo

2014/1/29

#
Thank you so much!
You need to login to post a reply.