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

2013/4/24

Convert Actor to Object

willnerd42 willnerd42

2013/4/24

#
I am getting an actor with getOneObjectAtOffset(), and I need to run a method on it. The problem is, it is of type Actor and you can't run methods that aren't in the Actor class. Any help?
Are you trying to run it in the world, because you need an actor to call that method.
davmac davmac

2013/4/24

#
You need a cast: ((ClassName)actor).methodName(); Where 'ClassName' is the name of the class of the actor (i.e. the class that defines the method you want to call), 'actor' is the reference to the actor, and 'methodName' is the name of the method you want to call.
You need to login to post a reply.