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

2013/10/26

Scrolling World Problem

RedCreeper RedCreeper

2013/10/26

#
I have uploaded my scenario (Actaeon). I'm experiencing a problem when i go to the next scrolling world, to experience the error yourself go to the game then take the path going to the left the actor that controls where the road leads to looks like a boy so that you can see it, just walk over it and you will see the error. The error is when the player intersects the nextWorld actor, the nextWorld will come up correctly but everything is in the wrong spot. But when i change it separately it works fine.
danpost danpost

2013/10/27

#
Did you fix this problem? I was not able to duplicate it.
RedCreeper RedCreeper

2013/10/27

#
No
danpost danpost

2013/10/27

#
I got no error when taking the left path and going into OverWorld #2.
RedCreeper RedCreeper

2013/10/27

#
there is no error report but when you go to the next world you should by at the far right edge. It has moved the actors from their location slightly up and to the left. I just looked at in my browser and got the error
danpost danpost

2013/10/27

#
To correct the starting location when changing grids, you can use the 'clearWorld' method to set the starting location of the main actor after calling 'prepare'.
RedCreeper RedCreeper

2013/10/27

#
I don't quite understand where would i put this because i already call clearWorld when the player intersects the nextLevel actor
danpost danpost

2013/10/27

#
I though I was clear enough ... maybe not. Put it in the 'clearWorld' method after the 'prepare();' statement. Something like:
if (gridNumber == 0) actaeon.setLocation(/* wherever */);
if (gridNumber == 1) /* etc */
RedCreeper RedCreeper

2013/10/27

#
Does it set the orgin to where ever the player is when it adds a actor
danpost danpost

2013/10/27

#
RedCreeper wrote...
Does it set the orgin to where ever the player is when it adds a actor
I am not sure as to what you are asking, here. I do not see what the question has to do with setting the location of the main actor when changing the grid. Please explain clearly what your concern deals with.
RedCreeper RedCreeper

2013/10/27

#
I was wondering if the world sets its origin to the main actor when it adds objects, I'm still getting the problem with the offset so I will update the scenario
danpost danpost

2013/10/27

#
I think your main problem comes from not knowing the scroll offset values when you are changing grids. Try moving the main actor to a place where you will know the scroll offset values before adding the new objects into the world; then move the main actor to where it needs to be. Such as:
// move main actor to top-left of scroll world
mainActor.setLocation(mainActor.geX()-1000, mainActor.getY()-1000);
super.act(); // sets scroll offset values to zero (top-left of scroll world)
// add objects (all positive coordinates)
// move main actor to start location for this grid
 super.act();
RedCreeper RedCreeper

2013/10/27

#
Does the code have to be possitive
danpost danpost

2013/10/27

#
Once the main actor is in the top-left corner of the scrolling world, everything right and below it would be positive. So, yes; otherwise you will be placing the objects outside the possible scroll areas.
You need to login to post a reply.