Game Development Reference
In-Depth Information
{
if (_tween.IsFinished() != true)
{
_tween.Process(elapsedTime);
_faceSprite.SetWidth((float)_tween.Value());
_faceSprite.SetHeight((float)_tween.Value());
}
if (_alphaTween.IsFinished() != true)
{
_alphaTween.Process(elapsedTime);
_color.Alpha = (float)_alphaTween.Value();
_faceSprite.SetColor(_color);
}
}
Another tween has been added. This tween takes the transparency of the sprite
from zero up to full opacity. This is a great method to use to fade in text.
The position of the sprite can also be altered with a tween. Try tweening the
sprite from off-screen to the center. Another good exercise would be to tween the
sprite opacity from zero to one and then set off a tween that will reverse it; twe-
ening from one to zero. These can then be called one after another, looping the
tween.
Matrices
Matrices are used throughout graphics programming. There are many different
applications of matrices, but this section will concentrate only on those related to
graphics and game programming.
Matrices are mathematical structures that provide a convenient way to describe
and perform a number of operations on a 3D model or sprite made from a quad.
These operations include transforming (moving the models around 3D space),
rotating, scaling, sheering (making the shape lean in a certain direction), and
projecting (the conversion of a point in 3D space to 2D space, for example).
Many of these operations can be done manually; for instance, our sprite class
already performs the translation operation by adding vectors to each vertex
position.
A matrix has several advantages over a vector when performing such operations.
Different matrices can be combined with their operation into a single matrix that
 
 
Search WWH ::




Custom Search