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

2012/4/17

unbounded world

mark.hayes mark.hayes

2012/4/17

#
have been trying to find some documentation on how to use an unbounded world. there are a couple of samples on the gallery, but I am looking for a simple example to show a beginning HS class. I follow the (brief) doc in the API, but would appreciate a bit more explanation on how to go about using an unbounded world.
nccb nccb

2012/4/17

#
By default in Greenfoot, the World class prevents any movement outside the bounds of the world. So if you try setLocation(-30, -10), it won't work (I think it silently fails?). The unbounded world relaxes this restriction, so that things can be "in" the world, but not in the visible portion in the Greenfoot IDE. It's mainly useful for doing things like scrolling shoot 'em-ups, or in things like physics simulations where you want an orbiting entity to have motion that takes it out of the world and back in again.
mark.hayes mark.hayes

2012/4/19

#
thanks. i follow that. what i am looking for is a way for the "viewport" to be moveable around the larger world. for example, if there are stationary actors that are outside the viewport, can they be brought into view, not by navigating them back into view, but by sliding the viewport vertically or horizontally to discover them? btw, is discussion traffic not pushed to the subscriber's email inbox?
mark.hayes mark.hayes

2012/4/19

#
sorry, my email notification was not set correctly. i have updated my profile to fix this.
nccb nccb

2012/4/19

#
I'm afraid greenfoot has no conception of a viewport. There is the world, which is displayed from 0,0 to width, height. If you want to scroll around a large world, you would need to do so by moving all the actors in the world (which is only four lines of code: get a list from the world and call setLocation on them).
You need to login to post a reply.