Jump to content

Cannot use frames from different sprite sheets for animation[Solved]


Igor Georgiev
 Share

Recommended Posts

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 by Igor Georgiev
Solved
Link to comment
Share on other sites

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 :D

Link to comment
Share on other sites

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

 Share

  • Recently Browsing   0 members

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