Game Development Reference
In-Depth Information
else
{
return distance * Math.Pow(2, 10 * (timePassed / duration - 1)) + start;
}
}
public static double EaseOutCirc(double timePassed, double start, double
distance, double duration)
{
return distance * Math.Sqrt(1 - (timePassed = timePassed / duration - 1) *
timePassed) + start;
}
public static double EaseInCirc(double timePassed, double start, double
distance, double duration)
{
return -distance * (Math.Sqrt(1 - (timePassed /= duration) * timePassed)
- 1) + start;
}
Using Tweens
Now that the tween class has been created, it is time to show off some of its
power. As always, this begins with a new game state being created. This one is
named TweenTestState .
This state requires the face texture used earlier in the topic to be added to the
project and its ''Copy To Output Directory'' property set to ''Copy if newer''. In
the
form constructor
the
face
texture
should be
loaded into the
TextureManager .
_textureManager.LoadTexture("face", "face_alpha.tif");
With the texture loaded it can be now be used to make a sprite in the Tween-
TestState class.
class TweenTestState : IGameObject
{
Sprite _faceSprite = new Sprite();
Renderer _renderer = new Renderer();
Tween _tween = new Tween(0, 256, 5);
public TweenTestState(TextureManager textureManager)
 
Search WWH ::




Custom Search