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

2014/11/21

Actor stops halfway at the edge of the world

akshay1188 akshay1188

2014/11/21

#
I am moving the actor using setLocation(int x, int y) method in downwards direction. The actor keeps moving downward until it crosses the bottom edge of the screen. But it halts halfway its height. How to make the actor pass continuously out of the world until it completely disappears?
Jonas097 Jonas097

2014/11/21

#
http://www.greenfoot.org/files/javadoc/greenfoot/World.html#World%28int,%20int,%20int,%20boolean%29 "bounded - Should actors be restricted to the world boundary?"
danpost danpost

2014/11/21

#
There are two constructors in the World class. One automatically sets the bounds for your actors to the edges of the world; the other allows you to specify if you want them bound as such or not. Be careful when setting an unbounded world that you keep tabs on all actors. Like if you have an actor that fires bullets and these bullets fly off the screen, they need to be removed. Otherwise, you will end up with a multitude of objects out there in nowheresland, which will eventually cause lag and maybe even an OutOfMemory issue.
akshay1188 akshay1188

2014/11/21

#
Beautiful! Thank you Jonas. Dan, I will make sure to keep a check on all my actors that go off the edge of the world. Thank you so much.
You need to login to post a reply.