Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public virtual void AnimateTransformTo(Vector2 position, float zoom, float speed, bool linear = true) {
- animateLinear = linear;
- animateEndPosition = position;
- animateEndZoom = zoom;
- animateSpeed = speed;
- animateTime = -1f;
- animateTransform = true;
- }
- public virtual void Update(GameTime gametime) {
- if (animateTransform) {
- if (animateTime == -1f) {
- animateStartPosition = m_position;
- animateStartZoom = m_zoom;
- animateTime = (float)gametime.TotalGameTime.TotalSeconds;
- OnAnimateTransformStart(this, new AnimateTransformEventArgs(animateTime, 0f, animateEndPosition, animateEndZoom, animateSpeed));
- }
- float time = (float)gametime.TotalGameTime.TotalSeconds;
- float progress = ((time - animateTime) / 100) * animateSpeed;
- if (progress >= 1f) progress = 1f;
- //if (animateLinear) LerpTransformLinear(animateStartPosition, animateEndPosition, animateStartZoom, animateEndZoom, progress);
- //else LerpTransformLinear(m_position, animateEndPosition, m_zoom, animateEndZoom, progress);
- if (animateLinear) LerpTransformLinear(out m_transform, new Vector2(m_viewport.Width, m_viewport.Height), animateStartPosition, animateEndPosition, animateStartZoom, animateEndZoom, progress);
- else LerpTransformLinear(out m_transform, new Vector2(m_viewport.Width, m_viewport.Height), m_position, animateEndPosition, m_zoom, animateEndZoom, progress);
- OnAnimateTransform(this, new AnimateTransformEventArgs(time, progress, animateEndPosition, animateEndZoom, animateSpeed));
- if (progress >= 1f) {
- animateTransform = false;
- OnAnimateTransformEnd(this, new AnimateTransformEventArgs(time, progress, animateEndPosition, animateEndZoom, animateSpeed));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement