Game Development Reference
In-Depth Information
{
_faceSprite.Texture = textureManager.Get("face");
}
#region IGameObject Members
public void Process(double elapsedTime)
{
if (_tween.IsFinished() != true)
{
_tween.Process(elapsedTime);
_faceSprite.SetWidth((float)_tween.Value());
_faceSprite.SetHeight((float)_tween.Value());
}
}
public void Render()
{
Gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
_renderer.DrawSprite(_faceSprite);
_renderer.Render();
}
#endregion
}
The tween increases the width and height of the sprite from 0 all the way up to
256. Run the code and check out the animation. The sprite will enlarge in a
smooth pleasing way. The next change is only a tiny modification to the code but
results in a big change.
Tween _tween = new Tween(0, 256, 5, Tween.EaseInExpo);
Run the program again and now the sprite will slowly expand. Then the change
will accelerate as it comes to full size. One small change has totally changed the
way the animation plays out. This is a great way to tweak existing animations.
Try the rest of the tween functions and see what they do, play around with the
rest of the arguments, and get a feel for how it all works.
Tween _alphaTween = new Tween(0, 1, 5, Tween.EaseInCirc);
Color _color = new Color(1, 1, 1, 0);
public void Process(double elapsedTime)
Search WWH ::




Custom Search