pluginProto.onCreate = function ()
{
// Override the 'set width' action
pluginProto.acts.SetWidth = function (w)
{
if (this.width !== w)
{
this.width = w;
this.text_changed = true; // also recalculate text wrapping
this.set_bbox_changed();
}
};
See the official text plugin.
The common ACEs could be found in commonace.js
Official function to create an instance
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;
}
}
};
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".
Subscribe to:
Posts (Atom)