This site requires JavaScript, please enable it in your browser!
Greenfoot
Username
Password
Remember Me?
Sign Up, Lost Password
Activity
About
Documentation
Download
Discuss
Scenarios
Lethal_Vitamin
wrote ...
2014/1/15
Accesing a Variable from Another Class
Lethal_Vitamin
2014/1/15
#
My Scenario
The question mark is supposed to be the total # of circles. I can't seem to access the variable totalCircles in my world class with it's getter in my counter class. Help!
danpost
2014/1/15
#
Greenfoot has a World class method that will return a List that you, in turn, can get the size of using a List class method:
// from an actor class int totalCircles = getWorld().getObjects(Circle.class).size();
No fields, no bother.
You need to login to post a reply.
X