Official function to create an instance, see system.js, line 1284.
SysActs.prototype.CreateObject = function (obj, layer, x, y)
{
if (!layer || !obj)
return;
var inst = this.runtime.createInstance(obj, layer, x, y);
if (!inst)
return;
this.runtime.isInOnDestroy++;
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);
}
}
this.runtime.isInOnDestroy--;
// Pick just this instance
var sol = obj.getCurrentSol();
sol.select_all = false;
sol.instances.length = 1;
sol.instances[0] = inst;
// Siblings aren't in instance lists yet, pick them manually
if (inst.is_contained)
{
for (i = 0, len = inst.siblings.length; i < len; i++)
{
s = inst.siblings[i];
sol = s.type.getCurrentSol();
sol.select_all = false;
sol.instances.length = 1;
sol.instances[0] = s;
}
}
};
Procedure of plugins and event sheet in each tick
- pretick() in plugins
- tick() in behaviors
- posttick() in behaviors
- tick() in plugins
- "condition: every tick" in event sheet
- tick2() in behaviors
- tick2() in plugins
- draw() in engine
Reference: preview.js, line 2416, function "logic".
Get behavior instance
function GetThisBehavior(inst)
{
var i, len;
for (i = 0, len = inst.behavior_insts.length; i < len; i++)
{
if (inst.behavior_insts[i] instanceof behaviorProto.Instance)
return inst.behavior_insts[i];
}
return null;
};
See the official DragnDrop behavior.
"behaviorProto" could be changed to specific behavior.
{
var i, len;
for (i = 0, len = inst.behavior_insts.length; i < len; i++)
{
if (inst.behavior_insts[i] instanceof behaviorProto.Instance)
return inst.behavior_insts[i];
}
return null;
};
See the official DragnDrop behavior.
"behaviorProto" could be changed to specific behavior.
Subscribe to:
Posts (Atom)