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
The issue occurs when defining an animation where the first frame has a duration of a few seconds. The AnimationController applies this duration before the first frame is even displayed, causing a noticeable lag when switching from another animation, like "WalkLeft," to the "Idle" animation. This delay results in the first frame of the "Idle" animation not appearing immediately, creating an undesirable pause during the transition.
//Define the "WalkLeft" animation
_spriteSheet.DefineAnimation("WalkLeft",builder =>{ builder.IsLooping(true).AddFrame("WalkLeft1", TimeSpan.FromSeconds(0.2)).AddFrame("WalkLeft2", TimeSpan.FromSeconds(0.2)).AddFrame("WalkLeft3", TimeSpan.FromSeconds(0.2)).AddFrame("WalkLeft4", TimeSpan.FromSeconds(0.2));});// Define the "Idle" animation
_spriteSheet.DefineAnimation("Idle",builder =>{ builder.IsLooping(true).AddFrame("Idle1", TimeSpan.FromSeconds(4)).AddFrame("Idle2", TimeSpan.FromSeconds(0.25));});
I believe the issue stems from the AnimationController's Play() Method
publicboolPlay(intstartingFrame){if(startingFrame<0||startingFrame >= _definition.FrameCount){thrownew ArgumentOutOfRangeException(nameof(startingFrame),$"{nameof(startingFrame)} cannot be less than zero or greater than or equal to the total number of frames in this {nameof(AnimationController)}");}// Cannot play something that is already playingif(IsAnimating){returnfalse;}IsAnimating=true;_internalFrame=startingFrame;CurrentFrameTimeRemaining= _definition.Frames[_internalFrame].Duration;returntrue;}
Because the CurrentFrameTimeRemaining is applied immediately the first frame's duration is being applied before the animation is shown
To fix this issue I commented out the CurrentFrameTimeRemaining line and set the CurrentFrameTimeRemaining to a TimeSpan of 0 so that the delay happens only after the first frame is rendered to the screen.
No worries if this is the intended behavior or if I'm not using it correctly, and I apologize if this proposed solution is causing any other issues. I really appreciate all the hard work your team is doing!
The text was updated successfully, but these errors were encountered:
The issue occurs when defining an animation where the first frame has a duration of a few seconds. The AnimationController applies this duration before the first frame is even displayed, causing a noticeable lag when switching from another animation, like "WalkLeft," to the "Idle" animation. This delay results in the first frame of the "Idle" animation not appearing immediately, creating an undesirable pause during the transition.
I believe the issue stems from the AnimationController's Play() Method
Because the CurrentFrameTimeRemaining is applied immediately the first frame's duration is being applied before the animation is shown
To fix this issue I commented out the CurrentFrameTimeRemaining line and set the CurrentFrameTimeRemaining to a TimeSpan of 0 so that the delay happens only after the first frame is rendered to the screen.
No worries if this is the intended behavior or if I'm not using it correctly, and I apologize if this proposed solution is causing any other issues. I really appreciate all the hard work your team is doing!
The text was updated successfully, but these errors were encountered: