/// <summary> /// Updates all logic for the button /// </summary> /// <param name="gameTime"></param> public override void Update(float gameTime) { switch (CurState) { case State.TransitionIn: // Advance time timer += gameTime; // Move the button dimensions.X = (int)EasingFunctions.Animate(timer, startPosition.X, endPosition.X, animTime, animType); dimensions.Y = (int)EasingFunctions.Animate(timer, startPosition.Y, endPosition.Y, animTime, animType); // If the button has reached its end point, set it to active if (timer >= animTime) { CurState = State.Active; } // Change the alpha if (alpha <= 1.0f) { alpha += changeRate * gameTime; } break; case State.TransitionOut: // Advance time timer -= gameTime; // Move the button dimensions.X = (int)EasingFunctions.Animate(timer, startPosition.X, endPosition.X, animTime, animType); dimensions.Y = (int)EasingFunctions.Animate(timer, startPosition.Y, endPosition.Y, animTime, animType); // If the button has reached its end point, set it to active if (timer <= 0.0f) { CurState = State.InActive; } // Change the alpha if (alpha >= 0.0f) { alpha -= changeRate * gameTime; } break; } }
public override void Update(float gameTime) { switch (CurState) { case State.TransitionIn: // Advance time timer += gameTime; position.X = (float)EasingFunctions.Animate(timer, startPosition.X, endPosition.X, animTime, animType); position.Y = (float)EasingFunctions.Animate(timer, startPosition.Y, endPosition.Y, animTime, animType); if (timer >= animTime) { CurState = State.Active; } if (alpha <= 1.0f) { alpha += changeRate * gameTime; } break; case State.TransitionOut: // Advance time timer -= gameTime; position.X = (float)EasingFunctions.Animate(timer, startPosition.X, endPosition.X, animTime, animType); position.Y = (float)EasingFunctions.Animate(timer, startPosition.Y, endPosition.Y, animTime, animType); if (timer <= 0.0f) { CurState = State.InActive; } if (alpha >= 0.0f) { alpha -= changeRate * gameTime; } break; } }
public override void Update(float gameTime) { switch (CurState) { case State.TransitionIn: timer += gameTime; switch (animDir) { case AnimationDirection.Left: dimensions.X = (int)EasingFunctions.Animate(timer, startPosition.X, endPosition.X, animTime, animType); break; case AnimationDirection.Right: dimensions.Width = (int)EasingFunctions.Animate(timer, startPosition.X, endPosition.X, animTime, animType); break; case AnimationDirection.Up: dimensions.Height = (int)EasingFunctions.Animate(timer, endPosition.Y, startPosition.Y, animTime, animType); break; case AnimationDirection.Down: dimensions.Height = (int)EasingFunctions.Animate(timer, 0, endPosition.Y, animTime, animType); break; } if (timer >= animTime) { CurState = State.Active; } // Move the bar //dimensions.Height = // (int)EasingFunctions.Animate(timer, startPosition.Y, -startPosition.Y, animTime, animType); // Change the alpha if (alpha <= maxAlpha) { alpha += changeRate * gameTime; } break; case State.TransitionOut: timer -= gameTime; // Move the bar switch (animDir) { case AnimationDirection.Left: dimensions.X = (int)EasingFunctions.Animate(timer, startPosition.X, endPosition.X, animTime, animType); break; case AnimationDirection.Right: dimensions.Width = (int)EasingFunctions.Animate(timer, startPosition.X, endPosition.X, animTime, animType); break; case AnimationDirection.Up: dimensions.Height = (int)EasingFunctions.Animate(timer, endPosition.Y, startPosition.Y, animTime, animType); break; case AnimationDirection.Down: dimensions.Height = (int)EasingFunctions.Animate(timer, 0, endPosition.Y, animTime, animType); break; } if (timer <= 0) { CurState = State.InActive; } // Change the alpha if (alpha >= 0.0f) { alpha -= changeRate * gameTime; } break; } }