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

2012/11/20

connecting methods from different classes

bonana bonana

2012/11/20

#
hey, how can I tell my world to do something if an object of a special class uses a special method? my code for that at the moment is:
if (classname.method())
{
       do something
}
it's wrong but I don't have an idea how to code that... hope you understand what I'm trying to say and that you can help me. :D
SPower SPower

2012/11/20

#
In the special method in the special class:
WorldName world = (WorldName) getWorld();
world.method();
where WorldName is the name of the class of your world, and method is the method which needs to be executed when the method gets executed.
bonana bonana

2012/11/20

#
Thanks, works! :-)
SPower SPower

2012/11/20

#
Great!
You need to login to post a reply.