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

2016/5/23

Get the nuber of Objects of one Class

1
2
BloodMate BloodMate

2016/5/23

#
*for any reason I can't write
[ ]
danpost danpost

2016/5/23

#
BloodMate wrote...
Ok... now "zombies" is the variable, right? When I use it like:
getWorld().addObject(zombies, 100, 300);
I get the error "greenfoot.Actor can not be converted to greenfoot.Actor", when I use:
getWorld().addObject(zombies[], 100, 300);
I get the Error " .class expected" and when I use zombie.class , it doesn't help too...
Yes, 'zombies' is a variable and it refers to the array. To refer to any object held by the array, you need a value (between 0 and 4, inclusive) between the square brackets following the array variable name. So, you would do this:
getWorld().addObject(zombies[0], 100, 300);
getWorld().addObject(zombies[1], 100, 100);
// etc.
danpost danpost

2016/5/23

#
BloodMate wrote...
*for any reason I can't write
[ ]
These are taken as tags in the text editor. This allows for 'bold', 'underline', 'code', links, etc..
BloodMate BloodMate

2016/5/23

#
It works Great! Thank you two
You need to login to post a reply.
1
2