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

2014/1/15

Accesing a Variable from Another Class

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