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

2013/5/9

Can you access variable information between actors by defined actors?

Entity1037 Entity1037

2013/5/9

#
Can you define an actor, and then send it variable information? I'm in a position where I can't really send information through world. So can you do something like:
Actor player = getOneObjectAtOffset(0,0,Player.class);
if (player!=null){
    //[insert code that sends information here]
}
Or is sending information through world the only way to do it?
Gevater_Tod4711 Gevater_Tod4711

2013/5/9

#
You can do this. The only problem is that your object is an Actor and in actor the method you want to use to send the information is probably not declared. So you will have to cast your player:
Actor player = getOneObjectAtOffset(0,0,Player.class);  
if (player!=null){  
    ((Player) player).receiveInformation();//or however your method is called.
} 
Entity1037 Entity1037

2013/5/9

#
I can work with that. Thanks!
You need to login to post a reply.