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


Variable from another world?

MrDoomsday MrDoomsday


I know how to access a variable from another actor but is there any way to access a variable of another world?
davmac davmac


Yes; worlds and actors are both objects and you can access them in the same way. Once you have a reference to the other world in a variable called 'otherWorld' you just use: otherWorld.variableName ... to access the variable.
IsVarious IsVarious


So for example if your variable was "pizzaLeft", you would declair it as 'public static int pizzaLeft;" this would enable you to access it from another level.
You need to login to post a reply.