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

Report as inappropriate.

MTK
MTK presents ...

2009/11/25

boundless-actor-test

I wrote a small class that allows an actor to go out of the bounds of the scenario freely.

I just did this by subclassing Actor and writing my own getX(), getY(), and setLocation() methods that don't implement bounds checking.

I am not sure whether collision detection works outside the view.

Move Tux with the arrow keys.

2661 views / 6 in the last 7 days

Tags: demo with-source scrolling boundless tux

open in greenfoot
Your browser does not support the canvas tag.
Builderboy2005Builderboy2005

2009/11/25

There is a fix for draging the object between acts. In the setLocation method, put in a call to super.setLocation(#,#) and then set your variables. This also helps with collision detection i believe.
Jesusgeek94Jesusgeek94

2009/11/25

isnt this just using the wanderer helper class on the greenfoot website?
MTKMTK

2009/11/25

Builderboy2005: There is a fix for draging the object between acts. In the setLocation method, put in a call to super.setLocation(#,#) and then set your variables. This also helps with collision detection i believe. If Greenfoot thinks the objects are against the edge when they are actually far away, won't collision detection be all wrong?
MTKMTK

2009/11/25

I see that when I don't use super.setLocation, collision doesn't work at all, but when I do, it works as if the object is against the wall (when is is actually far out of view), which would to some serious bugs in even a simple game.
Builderboy2005Builderboy2005

2009/11/25

Well, i would think having partial collision detection would be better than no collision detection at all, but i guess its all up to you. ...Unless you are willing to overide all of the collision methods as well XD
kenshinakhkenshinakh

2009/11/25

Well there's a way to do full collisions, and anything else even when the actors do not "appear" in the world. I think someone in the codepoint-general section showed something like that in his scenario. The way I figure is that it is made by overriding/creating a method that checks for collisions based on the x-y coordinates instead of the actual picture.
Builderboy2005Builderboy2005

2009/11/25

Yeah, that would have to be the way to do it.
MTKMTK

2009/11/25

That seems like a good way to do collisions.
jrlowejrlowe

2012/11/11

an easier way to do this is under the world constructor... public (WorldName) { super( 600, 400, 1, false); } you can just add false to the end of the parameter and it disables boundaries.
SPowerSPower

2012/11/11

@MTK what jrlowe says is indeed better, since collision detection won't get updated when you move.

See all comments

Want to leave a comment? You must first log in.

Who likes this?

No votes yet.