Unable to animate using AnimatedSprite
See original GitHub issueExpected Behavior
Player walking animation as in:
Current Behavior
Player switching animations but not changing frames in:
Often, if I change the frame using gotoAndPlay()
, the frame is set to this index in spite of emptying the cache while refreshing.
Possible Solution
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
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Unable to transition between AnimatedSprite animations
I want his animation to switch to "damaged" every time his hitbox overlaps with the player's sword, but it seems the animation won't...
Read more >Godot 3.2 - Use AnimationPlayer with AnimatedSprite - YouTube
Your browser can't play this video. ... Godot 3.2 - Use AnimationPlayer with AnimatedSprite. 7.4K views 3 years ago. Duroxxigar. Duroxxigar.
Read more >Support using AnimatedSprite and AnimationTree together #567
Simple 2D game with character animations. Describe the problem or limitation you are having in your project: I'm using AnimatedSprite for ...
Read more >Animated Sprite helpful class - Playdate Developer Forum
I wrote sprite class extension that supports imagetables, animation, finite state machine and json config.
Read more >Why doesn't my code use the correct animation?
AnimatedSprite is there to be used. And "I was told so" is not a good reason not to. Also, AnimatedSprite vs AnimationPlayer and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Vivraan I think your logic for
move
incorrectly calls every frame. This mean that it’s constantly settingtextures
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!
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.