Is this some obscure kind of fix?

For developers using the Construct 2 Javascript SDK

Post » Thu Nov 20, 2014 10:32 pm

Created a plugin that creates new instances of other plugin using the runtime's documented function createInstance.
While testing it, found that the "On created" condition was never triggered, to i took a look into the System CreateObject action. What I found was a little disturbing, checked out the Sprite's Spawn action and it did exactly the same disturbing thing:
It sets some undocumented runtime flag to true before triggering, and returns it to false just after that (See code below). What disturbed me more is that I tried it without the flag and worked without problems. (Maybe it's because I'm not using a container, or because the plugin doesn't have anything about drawing enabled, or some other reason).

I would like to know what can possibly go wrong if I create some instance and trigger OnCreated without setting that flag to true.

Code: Select all
SysActs.prototype.CreateObject = function (obj, layer, x, y)
if (!layer || !obj)

var inst = this.runtime.createInstance(obj, layer, x, y);

if (!inst)


var i, len, s;
this.runtime.trigger(Object.getPrototypeOf(obj.plugin).cnds.OnCreated, inst);

if (inst.is_contained)
   for (i = 0, len = inst.siblings.length; i < len; i++)
      s = inst.siblings[i];
      this.runtime.trigger(Object.getPrototypeOf(s.type.plugin).cnds.OnCreated, s);


Posts: 16
Reputation: 236

Post » Fri Nov 21, 2014 5:51 pm

You're talking about "isInOnDestroy"? I wouldn't worry about it, it's probably some kind of fix related to it's name.
Posts: 5,291
Reputation: 70,993

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 2 guests