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

2016/4/21

Scrolling world

1
2
3
4
danpost danpost

2016/5/1

#
GB309 wrote...
so I have sorted out the scrolling world but the only thing is that I want to spawn objects from the top of the screen down(which I have kind of solved), but when I call that method I cannot spawn them anywhere else but at the start of the map. What do I do?!
You should be able to use 'getScrolledX' on the scroller to get the current horizontal scroll amount. Then apply that to the horizontal positioning of the actor you wish to place into the world.
GB309 GB309

2016/5/1

#
I understand what you mean but I'm not sure how I'd put that into coding
GB309 GB309

2016/5/1

#
I'm not using the Img scroll btw, I'm using the scrolling super modified
danpost danpost

2016/5/1

#
GB309 wrote...
I'm not using the Img scroll btw, I'm using the scrolling super modified
If you are talking about my Scrolling SuperWorld, it also has a 'getScrolledX' method. If not, you will have to be more specific as to what scrolling system you are using.
GB309 GB309

2016/5/1

#
I am using yours but could u give me an example of how I could put this in the coding for an actor
GB309 GB309

2016/5/1

#
I am using yours but could u give me an example of how I could put this in the coding for an actor? thanks
GB309 GB309

2016/5/1

#
I am using yours but could u give me an example of how I could put this in the coding for an actor? thanks
GB309 GB309

2016/5/1

#
I am using yours but could u give me an example of how I could put this in the coding for an actor? thanks
danpost danpost

2016/5/1

#
GB309 wrote...
I am using yours but could u give me an example of how I could put this in the coding for an actor? thanks
The scenario you got the scrolling class from should provide an example.
GB309 GB309

2016/5/1

#
ok thanks
danpost danpost

2016/5/1

#
GB309 wrote...
ok thanks
You could even add the main actor, then set its location to (0, 0) and add the rest of the object at the coordinates with respect to the background image; then move the main actor again to its starting position.
GB309 GB309

2016/5/1

#
addObject(new enemy(),(getscrolledX(),getscrolledY());
GB309 GB309

2016/5/1

#
this doesn't work for me
GB309 GB309

2016/5/1

#
Am I writing the coding wrong?
danpost danpost

2016/5/1

#
GB309 wrote...
Am I writing the coding wrong?
I guess the easiest way to add objects into the world is to do the following: - set the main actor - set the location of the main actor to (-getScrolledX(0), -getScrolledY(0)) - call 'super.act();' to perform the scrolling (this may not place the actor at (0, 0) with respect to the scrolling area, but it should set the scrolled amounts to zero) - place objects into the world with respect to the scrolling area - set the main actor to its starting location with respect to the scrolling area -call 'super.act();' again to place (or ensure that) the actor in the window (or in the required range within the window). This system should work to initially place all your objects into the world.
There are more replies on the next page.
1
2
3
4