Help me to update plugins to support container

For developers using the Construct 2 Javascript SDK

Post » Mon Nov 19, 2012 11:23 pm

Hi, @Ashely

I have a lot of plugins which will set SOL like instance group, please help me to update plugins to support container in r110. Thanks.
(What's the changing for container?)


BTW, also please put "AddVariadicParams" into behavior when parsing edittime.js.rexrainbow2012-11-20 00:41:39
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Sun Nov 25, 2012 11:23 pm

@Ashely

Is this [code]objtype.applySolToContainer();[/code] correct to do container maintain?
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Wed Nov 28, 2012 5:04 pm

Anyone can help to rexrainbow?

If I know how I help Him but not

C2 Team???
B
60
S
9
G
7
Posts: 176
Reputation: 8,794

Post » Wed Nov 28, 2012 9:05 pm

rexrainbow - sorry I missed this thread (you typo'd my name so the forum didn't alert me)

Your proposed solution is correct, if you modify the SOL for an object, calling objtype.applySolToContainer() will set the corresponding SOLs in the container to have picked the instances corresponding to objtype. However, it's not particularly fast and should only be used in one-off places, like system's Create Object. If it's performance sensitive it gets a lot more complicated, but hopefully that call is enough for all your cases.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Thu Nov 29, 2012 1:00 am

@Ashley

Uh, sorry, I might typo'd your name many times.

And thanks for the response. I will fix my plugins to support container.

I found that engine used another code to maintain container in system:create object action.
[code]// Siblings aren't in instance lists yet, pick them manually
var i, len, s;
if (inst.is_contained)
{
    for (i = 0, len = inst.siblings.length; i < len; i++)
    {
        s = inst.siblings;
        sol = s.type.getCurrentSol();
        sol.select_all = false;
        sol.instances.length = 1;
        sol.instances[0] = s;
    }
}[/code]

Is it the same as [code]objtype.applySolToContainer();[/code]?rexrainbow2012-11-29 01:02:07
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Thu Nov 29, 2012 1:05 am

@rexrainbow - not quite, applySolToContainer() supports all the objects in the SOL whereas system's 'Create object' is setting each SOL to contain a single instance there. I forgot I changed that in a recent build to fix a bug: 'Spawn' and 'Create' specifically have to work around the fact the created instance isn't really created until the next top-level event, so they manually do similar work to what applySolToContainer does. Everywhere else applySolToContainer should be fine though.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Thu Nov 29, 2012 1:11 am

@Ashley

"Everywhere else applySolToContainer should be fine though"

Is it including "create object"-like action? I had some actions which will create instances. (or I just follow these code in system:create object)

And it seems engine will create other instances in the container by
[code]this.runtime.createInstance(obj, layer, x, y);[/code], so that we don't need to create them manually?rexrainbow2012-11-29 01:14:50
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Thu Nov 29, 2012 1:15 am

@rexrainbow - if you call createInstance, it will create the other objects in the container, but not pick them. You can't use applySolToContainer after createInstance, since the instance isn't really created until the next top-level event which breaks applySolToContainer. In that case, just copy the code from System's 'Create Object' (if picking works the same way and you just want to pick that one instance).
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Thu Nov 29, 2012 1:18 am

@Ashley

Thanks! I got it.
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest