Jump to content

EaselJS update animation inside the ticker


hiero314
 Share

Recommended Posts

Hello folks!

 

I'm building a game and I'm having an issue updating the sprite animation inside the ticker.

Bellow is my sprite.

var Hero = new createjs.Sprite(spritesheet, 'run');Hero.die = function() {game.Ticker.removeAllEventListeners();Hero.gotoAndPlay('death');});stage.addChild(Hero);
Inside the ticker function I check if the enemy colides with the hero
 
if(heroCollideBullet) Hero.die();

But animation its stuck on the frame 0.

 

 

Does anybody know any alternative changing the animation on ticker?

 

Thanks!

 

Link to comment
Share on other sites

  • 2 weeks later...

So the problem is that you're removing the listeners (game.ticker.removeAllEventListeners()) before the death animation can play out.  The way that Easel works is that the event ticker has an event listener which creates an animation frame event for whatever duration you specify (60 fps = 60 events per second, etc) and so if you remove the listener, you're basically telling the animation engine to stop animating.  What you really want to do is have the entire animation sequence play out and then set some flag on the hero object like Hero.dead = true, and have a condition in your ticker function that when hero.dead = true, remove all event listeners and reload the stage.  Hope that helps

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...