@@ -104,17 +104,15 @@ public void SetFrameClamp(float frame)
104104 }
105105
106106 /// <summary>
107- /// Smoothly changes the animation to a particular frame whilst clamping it to the frame count range.
107+ /// Smoothly changes the animation to a particular frame whilst clamping it to the frame count range,
108+ /// with adjustable animation speed (default 1 animation frame/sec).
108109 /// </summary>
109- public void UpdateFrameClamp ( float frame , ElapsedTime elapsedTime )
110+ public void UpdateFrameClamp ( float frame , ElapsedTime elapsedTime , float fps = 1.0f )
110111 {
111- float newState ;
112- if ( Math . Abs ( frame - AnimationKey ) > 10.0f * elapsedTime . ClockSeconds )
113- newState = AnimationKey + Math . Sign ( frame - AnimationKey ) * 10.0f * elapsedTime . ClockSeconds ;
112+ if ( Math . Abs ( frame - AnimationKey ) > elapsedTime . ClockSeconds * fps )
113+ SetFrameClamp ( AnimationKey + Math . Sign ( frame - AnimationKey ) * elapsedTime . ClockSeconds * fps ) ;
114114 else
115- newState = frame ;
116-
117- SetFrameClamp ( newState ) ;
115+ SetFrameClamp ( frame ) ;
118116 }
119117
120118 /// <summary>
@@ -147,20 +145,21 @@ public void SetState(bool state)
147145 }
148146
149147 /// <summary>
150- /// Updates an animated part that toggles between two states (e.g. pantograph, doors, mirrors).
148+ /// Updates an animated part that toggles between two states (e.g. pantograph, doors, mirrors),
149+ /// with adjustable animation speed (default 1 animation frame/sec).
151150 /// </summary>
152- public void UpdateState ( bool state , ElapsedTime elapsedTime )
151+ public void UpdateState ( bool state , ElapsedTime elapsedTime , float fps = 1.0f )
153152 {
154- SetFrameClamp ( AnimationKey + ( state ? 1 : - 1 ) * elapsedTime . ClockSeconds ) ;
153+ SetFrameClamp ( AnimationKey + ( state ? 1 : - 1 ) * elapsedTime . ClockSeconds * fps ) ;
155154 }
156155
157156 /// <summary>
158- /// Updates an animated part that toggles between two states and returns relative value of
159- /// animation key (between 0 and 1).
157+ /// Updates an animated part that toggles between two states with adjustable animation speed (default 1 animation frame/sec)
158+ /// and returns relative value of animation key (between 0 and 1).
160159 /// </summary>
161- public float UpdateAndReturnState ( bool state , ElapsedTime elapsedTime )
160+ public float UpdateAndReturnState ( bool state , ElapsedTime elapsedTime , float fps = 1.0f )
162161 {
163- SetFrameClamp ( AnimationKey + ( state ? 1 : - 1 ) * elapsedTime . ClockSeconds ) ;
162+ SetFrameClamp ( AnimationKey + ( state ? 1 : - 1 ) * elapsedTime . ClockSeconds * fps ) ;
164163 return AnimationKey / MaxFrame ;
165164 }
166165
0 commit comments