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

2014/6/29

Need a command for Greenfoot, have one but that doesn't work

1
2
Kutariyo Kutariyo

2014/6/29

#
So now I have: Wand aktWand = (Wand)this.getOneObjectAtOffset(0, 0, Wand.class); if (BördAufFeld () == true) { BördAufnehmen (); int wandCount = getWorld().getObjects(Wand.class).size(); int randomWand = Greenfoot.getRandomNumber(wandCount); Object wand = getWorld().getObjects(Wand.class).get(randomWand); this.getWorld().removeObject(aktWand); } No syntax errors but also a wand (wall) is not disappearing...
Kutariyo Kutariyo

2014/6/29

#
Oh sorry, didn't see your reply before. I now changet it to: getWorld().removeObject(Wand); but now there's a syntax error: cannot find symbol - variable Wand What now?
Kutariyo Kutariyo

2014/6/29

#
please write something I don't want to get a six tomorrow... :'(
danpost danpost

2014/6/29

#
The variable is not 'Wand', it is 'wand'.
Kutariyo Kutariyo

2014/6/29

#
then it says: removeObject(greenfoot.Actor) in greenfoot.World cannot be applied to (java.lang.object)
Kutariyo Kutariyo

2014/6/29

#
is the reason for this, that I wrote it into the class of the cat and not in the class of the wall. But I can't imagine that because it is about the cat because the cat does something and then something should happen so I can't write it inro the wall's class.
danpost danpost

2014/6/29

#
No. It is because I put it to a variable that holds an Object object instead of an Actor object. Change:
1
2
3
Object wand = getWorld().getObjects(Wand.class).get(randomWand);
// to
Actor wand = (Actor)getWorld().getObjects(Wand.class).get(randomWand);
Kutariyo Kutariyo

2014/6/30

#
Thank you very very much. Now everything is like it should be. And I added a menu for the game as well. It's my luck that we had not to present it in school today so I could complete it right now but only with your help. You safed my life. Thanks :)
You need to login to post a reply.
1
2