how to access commonActs from a behavior?

For developers using the Construct 2 Javascript SDK

Post » Wed Apr 05, 2017 6:49 pm

Thanks for that tip!
Okay, seems like it might be choosing the first instance of the objectType..
I believe by calling the ZMoveToObject it was expecting to be run in an event which would have a SOL..
var other = obj_.getFirstPicked(this);
is in the call, so I think it tried to pick from SOL.. so in this case it would always pick the first instance of the object apparently.

I went and copied the code into my behavior and replaced that so that it doesn't try to pick anything(since the behavior already has the object picked), and now it works..

So I guess I'll live with this unless anyone knows how to change the SOL??
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Post » Wed Apr 05, 2017 8:46 pm

From the sdk manual you can get the SOL:
https://www.scirra.com/manual/29/object-type

so you can get the current SOL with:
var sol = obj_.getCurrentSol();

The docs say to not modify other object's sol but I guess you could modify it, call that action, and then change the sol back to what it was.

Code: Select all
//save current
var old_instances = sol.instances;
var old_select_all = sol.select_all;

// set new
sol.instances = [this.pinObject];
sol.select_all = false;

// call action here

//restore old
sol.instances = old_instances;
sol.select_all = old_select_all;
B
94
S
33
G
113
Posts: 5,356
Reputation: 73,273

Post » Wed Apr 05, 2017 9:16 pm

nice, thanks for the info! That works great!
I feel like I've gained some new brain cells and can make better plugins/behaviors now. :)
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Previous

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests