You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was following the documentation but I'm seeing this issue where the first region of the atlas displays before the desired animation. In my code I've defined a sleep animation that does play, but before it plays the first region of the texture atlas (atlas) displays before.
@AristurtleDev: "The problem is how the AnimatedSprite(SpriteSheet, String) constructor is done when you call it by doing _dog = new AnimatedSprite(_spriteSheet, "sleep").
That constructor takes the _spriteSheet and calls the other constructor to set that up. Since AnimatedSprite is derived from Sprite, then it has to call the base constructor and pass in a texture to use, which just defaults to the first index in the texture atlas.
For right now, you should be able to fix this by instead doing the following workaround until a fix is pushed"
I ran into the same issue where the first region of the Texture2DAtlas was displaying before the desired animation and even with your workaround I still was running into this issue. I ended up having to fork and modify the source code to implement a working fix.
What I did to temporarily fix this was adding a custom constructor to AnimatedSprite to overwrite the broken one:
publicAnimatedSprite(SpriteSheet spriteSheet, int textureAtlasRegionIndex):base(spriteSheet.TextureAtlas[textureAtlasRegionIndex]){
ArgumentNullException.ThrowIfNull(spriteSheet);_spriteSheet=spriteSheet;}
and adding two custom methods to SpriteSheet that I use to try and get the Index of the First Texture2DRegion for my targeted Animation Frame:
So now when I create an AnimatedSprite I call these two methods with the name of the defined Animation which in your case was "sleep" and in my case its stored in the animationKey variable to get the first frame's index in the Texture Atlas and pass that to the new Animated Sprite like this :
Link to docs: https://www.monogameextended.net/docs/features/2d-animations/animatedsprite/
I was following the documentation but I'm seeing this issue where the first region of the atlas displays before the desired animation. In my code I've defined a sleep animation that does play, but before it plays the first region of the texture atlas (atlas) displays before.
@AristurtleDev: "The problem is how the AnimatedSprite(SpriteSheet, String) constructor is done when you call it by doing _dog = new AnimatedSprite(_spriteSheet, "sleep").
That constructor takes the _spriteSheet and calls the other constructor to set that up. Since AnimatedSprite is derived from Sprite, then it has to call the base constructor and pass in a texture to use, which just defaults to the first index in the texture atlas.
For right now, you should be able to fix this by instead doing the following workaround until a fix is pushed"
The text was updated successfully, but these errors were encountered: