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

2013/5/8

Checking if there is an actor in the world

GreenGoo GreenGoo

2013/5/8

#
What does getWorld().getObjects(Rocket.class) return if there are no objects of class Rocket in the world? It doesn't seem to be null...
getObjects() returns a List of the object you are looking for. If there is no actor of that class, it returns a List with a size of zero.
GreenGoo GreenGoo

2013/5/8

#
getWorld().getObjects(Rocket.class) != 0) says an error : incomparable types Java.util.List and int
GreenGoo GreenGoo

2013/5/8

#
Should I have imported something?
no, there's a method you forgot to call. Change: (getWorld().getObjects(Rocket.class) != 0) To: (getWorld().getObjects(Rocket.class).size() != 0) Like how arrays have a variable called length (arrayName.length), Lists have a size, which is called by that size method.
GreenGoo GreenGoo

2013/5/8

#
Thanks!
Your welcome
You need to login to post a reply.