Igor Georgiev Posted August 26, 2016 Share Posted August 26, 2016 (edited) He guys, I am trying to do following: var frameNames = Phaser.Animation.generateFrameNames(this.getColorById(this.gemId) + '_zap_explode_', 1, 13, '.png', 2); this.gem.animations.add('zapExplode', frameNames, this.fps, false); if the gem is from the same atlas, the other animations are playing correctly, but this one throws Uncaught TypeError: Cannot read property 'index' of undefined. Any ideas? Edited August 29, 2016 by Igor Georgiev Solved Link to comment Share on other sites More sharing options...
drhayes Posted August 26, 2016 Share Posted August 26, 2016 As far as I know, yes: you can only create animations in a single sprite from a single spritesheet or atlas. If those images were in a single atlas I think that would work fine. Link to comment Share on other sites More sharing options...
Igor Georgiev Posted August 26, 2016 Author Share Posted August 26, 2016 6 minutes ago, drhayes said: As far as I know, yes: you can only create animations in a single sprite from a single spritesheet or atlas. If those images were in a single atlas I think that would work fine. yeah, but the problem is, I got like 5 Link to comment Share on other sites More sharing options...
rich Posted August 26, 2016 Share Posted August 26, 2016 As DrHayes said, this can't currently be done. You need to chain the animations somehow, or wait for us to add it as a feature in v3. Link to comment Share on other sites More sharing options...
Igor Georgiev Posted August 29, 2016 Author Share Posted August 29, 2016 On 8/26/2016 at 7:20 PM, rich said: As DrHayes said, this can't currently be done. You need to chain the animations somehow, or wait for us to add it as a feature in v3. I understand, thank you. Will figure it out Link to comment Share on other sites More sharing options...
Igor Georgiev Posted August 29, 2016 Author Share Posted August 29, 2016 Guys, I fixed it by loading the atlas texture at the moment when I will need to play animation from another atlas. The following order must be followed. The sprite is being created and filled with whatever you want. On the moment you when you want to add frames and animation to the sprite from different atlas, you do this.someSprite.loadTexture('atlasKey'). After that you generate the frames with the Phaser.Animation.generateFrameNames, then you add the animation to the sprite and play it. After that you need to dispose of the sprite and recreate it if you want to use it with the old sprite sheet. Link to comment Share on other sites More sharing options...
symof Posted August 29, 2016 Share Posted August 29, 2016 Or you can make multiple objects can keep them in cache, then use kill and revive. It would probably be less performance taxing then disposing and recreating a sprite all the time. http://phaser.io/examples/v2/p2-physics/kill-and-revive Link to comment Share on other sites More sharing options...
Recommended Posts