Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createFromAseprite() consecutively #6434

Closed
yahoai opened this issue Mar 26, 2023 · 5 comments
Closed

createFromAseprite() consecutively #6434

yahoai opened this issue Mar 26, 2023 · 5 comments

Comments

@yahoai
Copy link

yahoai commented Mar 26, 2023

I am using Phaser version 3.55.2 and there is a bug where only one animation exists when the createFromAseprite function is used consecutively.

For example:

const BodyTags = s.anims.createFromAseprite("Body");
const HeadTags = s.anims.createFromAseprite("Head");

console.log(BodyTags[0].frames[0], HeadTags[0].frames[0]);

When used like this, the output is as shown in the screenshot. How can I fix this issue?

image

@photonstorm
Copy link
Collaborator

I need the assets to reproduce this, because it doesn't happen with the files I've got in the Phaser 3 Examples repo.

@yahoai
Copy link
Author

yahoai commented Mar 30, 2023

A sample asset file has been included. An "Idle" animation exists.
It is being loaded and used as follows:

scene.load.aseprite(
      "Head",
      "aseprite/player/test/MainChrHead.png",
      "aseprite/player/test/MainChrHead.json"
    );

    scene.load.aseprite(
      "Body",
      "aseprite/player/test/MainChr.png",
      "aseprite/player/test/MainChr.json"
    );

Please check it. Thank you.

Archive.zip

@photonstorm
Copy link
Collaborator

The problem is that both of your frameTags are called Idle and you're trying to add these to the same Sprite. So the second time you do it (with Head) it ignores it, because an animation with the key 'Idle' already exists (the one from Body).

If you want to use both animations on the same sprite you're going to have to rename them within Aseprite (BodyIdle, HeadIdle, etc) because in Phaser animations are key based and keys must be unique.

photonstorm added a commit that referenced this issue Mar 31, 2023
…State` if you try to add an animation with a key that already exists. Fix #6434
@yahoai
Copy link
Author

yahoai commented Apr 4, 2023

If customization is required for each part, it is expected to be more efficient to make common animation keys.

Any thoughts on updating?

@photonstorm
Copy link
Collaborator

No, this cannot be changed. Everything in Phaser 3 is string-key based, from textures to sounds to animations. If you want to add two animations to a single Sprite, they will need unique keys. It's as fundamental as that, I'm afraid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants