Change sprite animation speed with a Behavior

0 favourites
  • 2 posts
From the Asset Store
Carousel Animation, make carousel of you image gallery or anything
  • 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()
    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:
    	behinstProto.onCreate = function()
    		var self = this.inst;
    Do you have a better solution ?
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Using a boolean to indicate the first tick and then doing it in the tick function is a cleaner solution to me.

    behinstProto.onCreate = function()
       this.firstTick = true;
    behinstProto.tick = function()
       if (this.firstTick)
          this.firstTick = false;
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)