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

2013/12/5

Global Variable

Yedya Yedya

2013/12/5

#
I want to declare a global variable so all of my classes that inherit the actor class can access the varible,where would I declare it?
danpost danpost

2013/12/5

#
What kind of data will this global variable hold? for what purpose will it exist?
Yedya Yedya

2013/12/5

#
When a button is clicked,a boolean will be set to true and that will mean that every class will call a different method then what they would call if the boolean was set to falese.
danpost danpost

2013/12/5

#
OK, you have two possible locations: the first is in the world class; it can be non-static with 'get' and 'set' methods or it can be static; the other is in the button class where is would need to be static (unless you only create one button, in which case it could be non-static with 'get' and 'set' methods; For ease of coding, a 'public static boolean' in the world class may be the way to go. Then you can access and change the value from any class by using 'WorldClassName.fieldName' to refer to the field.
Yedya Yedya

2013/12/7

#
Working now thanks
You need to login to post a reply.