Behavior accessing a plugin?

For developers using the Construct 2 Javascript SDK

Post » Sun Jun 10, 2012 6:42 pm

[QUOTE=rexrainbow] This is a method to call plugin's action from behavior, so that behavior could extend plugin by calling plugin's action.
[code]cr.plugins_.Text.prototype.acts.SetText.apply(this.inst, [param]);[/code]

This could call other behavior's action. It's also useful, too.
[code]cr.behaviors.Physics.prototype.acts.ApplyForceToward.apply(this.physics_behavior_inst, [f, px, py, 0]);[/code][/QUOTE]

Nice! Thanks Rex. Unless you've already updated the function plugin could you have it so if you try and run a string that isn't set as a function it doesn't throw an error saying the function doesn't exist? Would ignoring be better than throwing an error? Anyway thanks for the contribution. I'm using it for an event system.
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Wed Jun 13, 2012 3:54 am

@00Rez

Function plugin has debug mode property which could be used to check calling inexistent function name. Default is "Off".
B
97
S
22
G
176
Posts: 4,109
Reputation: 103,021

Post » Sat Jul 28, 2012 1:35 am

Another way to use other plugin in behavior.

1. get "type" (or class in OO)
this.type.canvas_type = canvas_type

2. create plugin instance by this.runtime.createInstance
this.canvas_inst = this.runtime.createInstance(canvas_type,_layer,_x,_y)

3. remove the instance when behavior destroyed.
this.runtime.DestroyInstance(this.canvas_inst)rexrainbow2012-07-28 01:37:11
B
97
S
22
G
176
Posts: 4,109
Reputation: 103,021

Previous

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest