Report as inappropriate.

No_avatar_thumb

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.

824 views / 2 in the last 7 days

Tags: demo with-source scrolling boundless tux

open in greenfoot
Your browser is ignoring the <APPLET> tag.
No_avatarMTK

2009/11/25

And I forgot to say that one side effect of this technique is that you can't drag the actors when the scenario is paused. The initial placement works normally, however.
No_avatar_thumbBlackholeGF

2009/11/25

Nice! My ecobear scenario uses a much more complex method of scrolling, which isn't as smooth.
Avatar-1940Builderboy2005

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.
Ddr_left_arrow_thumbJesusgeek94

2009/11/25

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

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?
No_avatarMTK

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.
Avatar-1940Builderboy2005

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
No_avatarkenshinakh

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.
Avatar-1940_thumbBuilderboy2005

2009/11/25

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

2009/11/25

That seems like a good way to do collisions.

See all comments

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

Who likes this?

No votes yet.