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

2012/10/13

Actor into java.lang.class

1
2
HayleyG HayleyG

2012/10/13

#
How do you convert an actor into java.lang.class?
SPower SPower

2012/10/13

#
Well, what are you trying to accomplish?
HayleyG HayleyG

2012/10/13

#
trying to remove squares World world; world = getWorld(); Square square; square = world.getObjects(square); world.removeObject(square);
SPower SPower

2012/10/13

#
If you're trying to remove a list of squares, do this:
getWorld().removeObjects(getWorld().getObjects(Square.class));
HayleyG HayleyG

2012/10/13

#
Thanks :D
SPower 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 HayleyG

2012/10/13

#
?
HayleyG HayleyG

2012/10/13

#
only just started learning Greenfoot
SPower 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 HayleyG

2012/10/13

#
I understand now
HayleyG HayleyG

2012/10/13

#
The error message told me to convert it
SPower SPower

2012/10/13

#
What did it tell exactly?
HayleyG 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 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 HayleyG

2012/10/13

#
but it said: required: java.lang.Class
There are more replies on the next page.
1
2