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

2012/5/15

Variable from another world?

MrDoomsday MrDoomsday

2012/5/15

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

2012/5/16

#
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

2012/5/24

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