Igor Georgiev

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

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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.