Call Behaviorfunction from Plugin

For developers using the Construct 2 Javascript SDK

Post » Sat Feb 02, 2013 11:37 am

Hello

i have a Question. I have a Behavior and a Plugin and i want to call a function in the Behavior from the Plugin. Is this Possible ?

For example i got 3 Enemys with Behavior "Enemy". Now i want that the plugin is calling the Function "OnMove" of all 3 Enemys. How can i do that ?

This is my Function in the Behavior

[CODE]
behinstProto.OnMove = function (playerData)
     {     
          this.runtime.trigger(cr.behaviors.Otherplayer.prototype.cnds.OnMove, this.inst);
     };
[/CODE]

so i want to call this by using in my Plugin

[CODE]

cr.behaviors.Otherplayer.OnMove(data)

[/CODE]

anybody can help
B
4
Posts: 11
Reputation: 797

Post » Sun Feb 03, 2013 7:40 am

Nobody ? Please help me !
B
4
Posts: 11
Reputation: 797

Post » Wed Feb 06, 2013 9:11 pm

Nice support .......
B
4
Posts: 11
Reputation: 797

Post » Mon Feb 11, 2013 12:11 am

@Codebase

You need to get the reference of instance(sprite, maybe), then get the reference of behavior, finally you could get the reference of this function in the behavior.
B
97
S
22
G
176
Posts: 4,109
Reputation: 103,021

Post » Mon Feb 11, 2013 12:12 am

@Codebase

Or another way, register function in the behavior into the plugin, so that you could get the function reference directly. Just remember clean the reference when instance destroyed.
B
97
S
22
G
176
Posts: 4,109
Reputation: 103,021


Return to Javascript SDK

Who is online

Users browsing this forum: zrt720 and 0 guests