hiero314 Posted November 4, 2015 Share Posted November 4, 2015 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! Quote Link to comment Share on other sites More sharing options...
Suiname Posted November 16, 2015 Share Posted November 16, 2015 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.