Get a reference to that actor you want the info from and call the 'get' methods that return that info on that actor. It only be cast as actor, so if you get that reference by way of an Actor class method you should not need to typecast the returned object (actor); otherwise (if you use a World class method), you will need type typecast the returned object at least as an Actor object.
For example:
((Actor)getWorld().getObjects(ActorClassName.class).get(0)).methodName();
'getWorld().getObjects(...).get(0)' returns an object, not an Actor, so you could not call Actor class method on it directly. NOTE: the 'get(0)' call will fail if not actors of that type are in the world.
Typecasting it with '(Actor)...' tells the system that it is indeed an Actor object and Actor class method can be then used on the object.
whoa whoa whoa. slow down. so, the example of the code you gave me, that would go in the class that I want to get the info, right? and what would I put for methodName()?
whoa whoa whoa. slow down. so, the example of the code you gave me, that would go in the class that I want to get the info, right? and what would I put for methodName()?
The name of the method you are calling in the ActorClassName class for that ActorClassName object.
I tryed this, and it worked, but like you said, it didn't work when there was no object of the class in the world. Is there a way to check if it is not null first?
if (getWorld().getObjects(ActorClassName.class).size() > 0)
or
if (!getWorld().getObjects(ActorClassName.class).isEmpty())
They both will return true if there are any actors of that class in the world; however, the second one is more efficient in that it will not count all the objects of that type, but immediately return as soon as one is found (if any are).