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

Report as inappropriate.

mjrb4
mjrb4 presents ...

2009/7/4

Wanderer Demo

Here's a quick demo of the Wanderer helper class - actors that extend this class will be able to call setLocation even to go somewhere off screen. The co-ordinates are still stored, and when the actor enters the world again it will become visible.

UPDATE: As of Greenfoot 2.0 this helper class / scenario is redundant - there is a new constructor on World that states whether the world is bounded or unbounded, so this functionality is built in!

9379 views / 21 in the last 7 days

Tags: demo with-source

This scenario is a member of: Reusable actors & support classes


open in greenfoot
Your browser does not support the canvas tag.
This is awesome! The code I'd need to make a better platform... :)
tombud999tombud999

2009/8/8

Hi, I would like to have this Wanderer effect in my Tossing scenario that using SmoothMover & Vector class. Which methods should I override?
mjrb4mjrb4

2009/8/8

You just need to download the source and put the wanderer class in your scenario so it's a superclass of whatever you want to "wander." So if you put it in your project and then do something like: public class Ball extends Wanderer and then edit wanderer to extend whatever Ball was previously extending, it should work. (Obviously replace ball with whatever actor it is you want to wander outside the world!)
tombud999tombud999

2009/8/9

I just modified SmoothMoverWithGravity class to extends Wanderer class, and hey! it works perfectly! :D Thanks alot, Michael !
The collision doesn't work properly! how do I solve that problem?
never mind... Maybe one can override the collision codes (get the code at the source code from some old version of greenfoot)
mjrb4mjrb4

2009/8/18

Sorry, I haven't had a chance to test this out yet! Is it just with actors that extend the Wanderer class? I thought it worked ok for me when I tested it... I'll have another look at some point.
I finally wrote codes to override collision offscreen! :D :D :D :D :D :D (one now can use the getOneIntersectingObject and other similar methods)
PiRocksPiRocks

2010/10/5

lime, I was just about to do the same thing but since you have already done it.. Where can I find your code? (I don't like reinventing the wheel - even if it does give you a pair of wheels....)
davmacdavmac

2010/10/6

Greenfoot 2.0 has just been released and includes full support for unbounded worlds, including off-screen collision checking. As well as a bunch of other cool features! To create an unbounded world, add an additional "false" argument when you call the World class constructor, eg "super(500,500,1,false);".

See all comments

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

Who likes this?

No votes yet.