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
HayleyG
wrote ...
2012/10/13
Actor into java.lang.class
1
2
HayleyG
2012/10/13
#
How do you convert an actor into java.lang.class?
SPower
2012/10/13
#
Well, what are you trying to accomplish?
HayleyG
2012/10/13
#
trying to remove squares World world; world = getWorld(); Square square; square = world.getObjects(square); world.removeObject(square);
SPower
2012/10/13
#
If you're trying to remove a list of squares, do this:
getWorld().removeObjects(getWorld().getObjects(Square.class));
HayleyG
2012/10/13
#
Thanks :D
SPower
2012/10/13
#
Some advice: you can't convert it into a Class class ( :-) ), because it hasn't got it as it's superclass.
HayleyG
2012/10/13
#
?
HayleyG
2012/10/13
#
only just started learning Greenfoot
SPower
2012/10/13
#
You wanted to convert an Actor object to an Class object, but the Actors superclass isn't Class but Object. This is why you can't convert it.
HayleyG
2012/10/13
#
I understand now
HayleyG
2012/10/13
#
The error message told me to convert it
SPower
2012/10/13
#
What did it tell exactly?
HayleyG
2012/10/13
#
method getObjects in class greenfoot.World cannot be applied to given types; required: java.lang.Class found: Square reason: actual argument Square cannot be converted to java.lang.Class by method.
SPower
2012/10/13
#
It didn't tell you you had to convert it, it said:
actual argument Square
cannot
be converted to java.lang.Class by method
:)
HayleyG
2012/10/13
#
but it said: required: java.lang.Class
There are more replies on the next page.
1
2
X