I noticed that it was a common problem around here so I decided to play around with it because I thought that not letting actors out the visible part of the world was a serious limitation of Greenfoot. Maybe I can play around with scrolling sometime later!
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.
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.
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?
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.
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
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.
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.
2009/11/25
2009/11/25
2009/11/25
2009/11/25
2009/11/25
2009/11/25
2009/11/25
2009/11/25
2009/11/25
2009/11/25
2009/11/25
2009/11/25
2009/11/25
2012/11/11
2012/11/11