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

2016/12/9

Scrolling Map - Large Image

1
2
Kazee Kazee

2016/12/12

#
danpost wrote...
Kazee wrote...
In first, is easy because the world is created with the walls, but while the actor walk to the right, how I can create new walls? In the positions of those red square?
They are part of the same world, you can add them when the world is created as well.
I know but, how i can know what exactly is the X and Y for that? Because when I move to the right X and Y "restart" to 0 and increases to 800. So. If I add a wall in x 400 and y 40, those walls will not be later on the map. I do not know if I can explain myself.
danpost danpost

2016/12/12

#
Kazee wrote...
I know but, how i can know what exactly is the X and Y for that? Because when I move to the right X and Y "restart" to 0 and increases to 800. So. If I add a wall in x 400 and y 40, those walls will not be later on the map.
You can determine the amount of x and y to add by the 'getScrolledX' and 'getScrolledY' methods (just add their values to the 'getX' and 'getY' values). Except that since those methods are part of the Scroller object and not part of the World or any Actor object, executing those methods while the scenario is stopped would be impossible. Add the following codes to your World subclass:
// instance fields
public int sX, sY;

// as last lines in act method
sX = scroller.getScrolledX;
sY = scroller.getScrolledY;
Then you will be able to inspect the World object and get their values.
You need to login to post a reply.
1
2