Search the Community
Showing results for tags 'AnimationManager'.
-
Let say, with `sprite.animations.add("run");` I add an animation to an AnimationManager object. How can I see what animations are already there? Looking through, it is actually in `sprite.animations._anims` but it is listed as an object that cannot be read systematically (for example, `sprite.animations._anims[0]`).
-
Hello everyone i was wonder is there a way to make the AnimationManager instance shareable. so that when i create a new instance of my sprite,i don't need to add animations once a Sprite instance create . //this is the current way class Player extends Phaser.Sprite { contractor(game) { super(game,0,0,'player'); this.animations.add('walk',[0,1,2,3]); this.animations.add('run',[4,5,6,7]); } } that's a waste of memory,and if i create a lot sprite instances same time,a big JAM would happen so, i wanna this way var animationManager=new Phaser.AnimationManager(); //add animations animationManager.add('walk',[0,1,2,3]); animationManager.add('run',[4,5,6,7]); //then i create 2 players var playerA=new Player(game) playerA.animations=animationManager; var playerB=new Player(game) playerB.animations=animationManager; //////////////even thought that animationManger instance shoud be a static variable and declare inside of the Player class/////////////// class Player extends Phaser.Sprite { static animationManager; contractor(game) { super(game,0,0,'player'); if(Player.animationManager==null) { //register animations here } this.animations=Player.animationManager; } }
-
Hello ! I have a quite simple problem (Phaser 2.0.2). On a custom Sprite with an animation, I call sprite.Destroy() when the animation is complete but then it throws me "TypeError: this.currentAnim is null" (line 37562). Here's my code: SpecialFX = function(_x, _y, _spriteName) { Phaser.Sprite.call(this, game, _x, _y, _spriteName); this.animIdle = this.animations.add('idle', [0, 1, 2, 3, 4], 10, false); this.animIdle.onComplete.add(this.animationStopped, this); this.animations.play('idle'); game.add.existing(this);};SpecialFX.prototype = Object.create(Phaser.Sprite.prototype);SpecialFX.prototype.constructor = SpecialFX;SpecialFX.prototype.animationStopped = function() { this.destroy();};It looks like the AnimationManager attached to my sprite is not destroyed and still try to update. Thank you in advance.
-
With this code: tempBrick.animations.add('idle', ['brick_' + bID + '_1.png'], 10, false, false); tempBrick.animations.add('brick_die', [ 'brick_' + bID + '_1.png', 'brick_' + bID + '_2.png', 'brick_' + bID + '_3.png', 'brick_' + bID + '_4.png' ], 10, false, false); tempBrick.animations.add('brick_popin', [ 'brick_' + bID + '_4.png', 'brick_' + bID + '_3.png', 'brick_' + bID + '_2.png', 'brick_' + bID + '_1.png' ], 10, false, false);And then later I want to play and add custom callback when animation is played: I saw that there is: onComplete() and also a onAnimationComplete event but for that I need the animation instance... So what i thought is to get the instance from the sprite.animations ... something like sprite.animations.get("brick_die"); But the animationMnager doesn't have such a thing... there is a /*** @property {object} _anims - An internal object that stores all of the Animation instances.* @private*/ this._anims = {}; But I don't think it's supposed to be used... Also I could make a instance once I'm adding them to the sprite.animation like: var IdleBrickAnimation = tempBrick.animations.add('idle', ['brick_' + bID + '_1.png'], 10, false, false); and then: IdleBrickAnimation.onComplete(myCallBack); But since I do it in the different places and methods I expected that there is a way to get a animation by name and then play it and add a callback specifically for this play.
- 3 replies
-
- AnimationManager
- spirte.animations
-
(and 2 more)
Tagged with: