Animations in Code
Introduction
Animations and Instructions
Simple Animation Example
FlatRedBall.Gum.Animation.GumAnimation MoveAroundAnimation;
IEnumerable<Instruction> GetMoveInstructions(object target)
{
yield return new DelegateInstruction(() => { ButtonInstance.X = 100; ButtonInstance.Y = 10; })
{
Target = target,
TimeToExecute = TimeManager.CurrentTime + 0
};
yield return new DelegateInstruction(() => ButtonInstance.Y = 200)
{
Target = target,
TimeToExecute = TimeManager.CurrentTime + 1
};
yield return new DelegateInstruction(() => ButtonInstance.X = 400)
{
Target = target,
TimeToExecute = TimeManager.CurrentTime + 2
};
}
void CustomInitialize()
{
MoveAroundAnimation = new FlatRedBall.Gum.Animation.GumAnimation(5, GetMoveInstructions);
}
void CustomActivity(bool firstTimeCalled)
{
if(InputManager.Keyboard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.Space))
{
MoveAroundAnimation.Play();
}
}
GetMoveInstructions
Last updated
Was this helpful?