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

Unable to animate using AnimatedSprite #7136

Closed
Vivraan opened this issue Jan 11, 2021 · 8 comments
Closed

Unable to animate using AnimatedSprite #7136

Vivraan opened this issue Jan 11, 2021 · 8 comments
Labels
👍 Not A Bug Verified issue and is working as intended. 🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim

Comments

@Vivraan
Copy link

Vivraan commented Jan 11, 2021

Expected Behavior

Player walking animation as in:

This.is.Mario50.2021-01-10.17-00-00.mp4

Current Behavior

Player switching animations but not changing frames in:

screen-recorder-sun-jan-10-2021-17-00-57.mp4

Often, if I change the frame using gotoAndPlay(), the frame is set to this index in spite of emptying the cache while refreshing.

This.is.Mario50.and.11.more.pages.-.Personal.-.Microsoft.Edge.2021-01-11.12-38-14.mp4

Possible Solution

https://gitlab.com/Vivraan/mario50-pixijs/-/blob/227a18672242d9c468274e6a50c53cff1adda7f2/player.js#L63-73

        const move = (dt) => {
            if (this._vx != 0) {
                this._anim.textures = animations.walking
                if (!this._anim.playing) {
                    this._anim.play()
                }
                this._anim.scale.x = Math.sign(this._vx)
            } else {
                this._anim.textures = animations.idle
            }
        }

Steps to Reproduce

I raised this issue as a question rather than a bug report. The commit I'm working from is this one, which summarises the repro steps.

Environment

  • pixi.js version: ^5.3.7
  • Browser & Version: MS Edge 84.0.522.52 (Chromium)
  • OS & Version: Windows 10 20H2 19042.685
  • Running Example: Repo in GitLab
@bigtimebuddy
Copy link
Member

@Vivraan I think your logic for move incorrectly calls every frame. This mean that it's constantly setting textures on your animation frame after frame. If you cache the previous direction to only handle changes, it's better.

Here's an isolated example (click on the character on the right and then use the left and right arrow keys to see the animation switch). https://jsfiddle.net/bigtimebuddy/qo12kdnj/

This is not a limitation of the AnimatedSprite. In your case, this is an appropriate use.

Also, for questions (not bugs) please post to the Discussion section Q&A instead. Thanks!

@bigtimebuddy bigtimebuddy added 👍 Not A Bug Verified issue and is working as intended. 🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim labels Jan 11, 2021
@pixijs pixijs deleted a comment from ivanpopelyshev Jan 12, 2021
@Vivraan
Copy link
Author

Vivraan commented Jan 12, 2021

@Vivraan I think your logic for move incorrectly calls every frame. This mean that it's constantly setting textures on your animation frame after frame. If you cache the previous direction to only handle changes, it's better.

Here's an isolated example (click on the character on the right and then use the left and right arrow keys to see the animation switch). https://jsfiddle.net/bigtimebuddy/qo12kdnj/

This is not a limitation of the AnimatedSprite. In your case, this is an appropriate use.

Also, for questions (not bugs) please post to the Discussion section Q&A instead. Thanks!

Yeah, I just got acquainted with Discussions recently. Will keep this in mind.

@bigtimebuddy
Copy link
Member

Awesome, will close this issue. Good luck with your project!

@Vivraan
Copy link
Author

Vivraan commented Jan 12, 2021

Awesome, will close this issue. Good luck with your project!

Hey @bigtimebuddy I just tried your solution but I still can't get it to work.
Should I raise this in Discussions?

@bigtimebuddy
Copy link
Member

Yes, a discussion is good for this.

@Vivraan
Copy link
Author

Vivraan commented Jan 12, 2021

I've tagged you in the Q&A section. I suppose I need to do more work on this.

@Vivraan
Copy link
Author

Vivraan commented Jan 18, 2021

@bigtimebuddy Please check out #7144! Haven't seen any responses there!

Apologies for tag-spamming in so many places!

@bigtimebuddy
Copy link
Member

I see your tagging. I unfortunately cannot help you debug your project at the moment, sorry. Hopefully someone else will be able to chime in. Good luck and keep at it, I'm sure you'll figure it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👍 Not A Bug Verified issue and is working as intended. 🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim
Projects
None yet
Development

No branches or pull requests

2 participants