Hi!
How can I count how many objects I have in onw class?
I added the objects in My World editor, with a while loop, and I counted the objects in the i variable, but I can't use this variable in other editor.
int i=0; int x=Greenfoot.getRandomNumber(600); int y=Greenfoot.getRandomNumber(400); while (i<5) { addObject (new Alien(),x,y); i++; addObject (new Planet (), x+Greenfoot.getRandomNumber(200), y+Greenfoot.getRandomNumber(200)); x=Greenfoot.getRandomNumber(600); y=Greenfoot.getRandomNumber(400); if (x==100) { while (x==100) {x=Greenfoot.getRandomNumber(600);} } if (y==200) { while (y==200) {y=Greenfoot.getRandomNumber(400);} } }