Hi,
I'm making a behavior that's supposed to be attached to Sprite objects.
I want that behavior to set the animation speed of the sprite once that sprite is created.
And this is what I do in the behavior:
behinstProto.onCreate = function()
{
cr.plugins_.Sprite.prototype.acts.SetAnimSpeed.call(this.inst,0);
};
[/code:3d8r6s5s]
Unfortunately that does nothing, because apparently the sprite object's instantiation/initialization comes after behinstProto.onCreate() and override my setting.
One solution is to put it in behinstProto.tick() but I don't want to add initialization stuff in the tick function.
One other hackish solution:
[code:3d8r6s5s]
behinstProto.onCreate = function()
{
var self = this.inst;
setTimeout(function(){
cr.plugins_.Sprite.prototype.acts.SetAnimSpeed.call(self,0);
},0);
};
[/code:3d8r6s5s]
Do you have a better solution ?
Thanks.