Animated Sprite Current Time Infinity on Tab Change
See original GitHub issueHey guys, I found an issue with Animated Sprites / Movie Clip. When I change tabs with an animation running, the whole game breaks.
When you have a running animation, the current frame is calculated with this:
AnimatesSprite.js 372: var currentFrame = Math.floor(this._currentTime) % this._textures.length;
However, when you change tab, this._currentTime is being set to Infinity, and so this._currentFrame is being set to NaN. This in turn causes this._textures[this._currentFrame] to return undefined and then the renderer crashes because an invalid texture has been set on the sprite.
I did a quick isFinite stop this from breaking the renderer.
` get: function get() {
if(!isFinite(this._currentTime)) {
this._currentTime = 0;
}
var currentFrame = Math.floor(this._currentTime) % this._textures.length;
if (currentFrame < 0) {
currentFrame += this._textures.length;
}
return currentFrame;
} `
Hope this might help someone else too!
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Animated Sprite Current Time Infinity on Tab Change #3709
Hey guys, I found an issue with Animated Sprites / Movie Clip. When I change tabs with an animation running, the whole game...
Read more >Animation
The animation property in CSS can be used to animate many other CSS properties such as color, background-color, height, or width.
Read more >Sprites not loading on canvas
I'm trying to create a game with sprite animation, but I can't seem to load both the animated sprite and the canvas at...
Read more >2D ANIMATION RIGGING IN UNITY | PNG & PSB FILES
In this Unity tutorial we will create a Sprite animation in Unity! We will be animating using Unity's bone rigging, and I will...
Read more >Animated Sprite & Sprite Frame | Godot Basics Tutorial | Ep 60
Welcome to the Godot Basics Tutorial Series, in this episode I take a quick and brief look at the Animated Sprite and Sprite...
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 Free
Top 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
Sorry I completely forgot… let me try and get one done tonight 😃
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.