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

2011/11/22

accesing variables in another class

styxtwo styxtwo

2011/11/22

#
I have a variable in my world class called MAXHEIGHT, is here any way i can access this variable in a class that does not inherit the world class? Thanks in advance, styxtwo EDIT: i would also like to know if there is any way to trace a variable :). I couldn't find it anywhere :(
danpost danpost

2011/11/22

#
With a world variable such as: public int varName = 3; Use: ((WorldType) getWorld()).varName where WorldType is the name of the World class that varName resides. As far as tracing a variable you could write it to the terminal using: System.out.println(Text text) You can use: IntegerToText(); or: "" + varName, to force them to text
styxtwo styxtwo

2011/11/23

#
Thanks for your reply, it is very helpful :).
You need to login to post a reply.