AnimationRuntime

Introduction

AnimationRuntime is a class containing a list of keyframes (of type KeyframeRuntimeInstance). AnimationRuntime instances can be used to modify variables on a GraphicalUiElement over time .

AnimationRuntime instances can be created from animations defined in the Gum tool or by hand in code. For information on how to create an animation in the Gum Tool, see the Animation Tutorials section.

Code Example - Loading Animations from Gum Project

Animations defined in the Gum tool can be loaded at runtime. To load and play an animation, the following calls are needed:

  1. Call GumService.LoadAnimations

  2. Obtain an AnimationRuntime instance from your GraphicalUiElement

  3. Call ApplyAtTimeTo to apply the animation at runtime.

The following code shows how to load the first screen in a Gum project and how to play its animation.

GraphicalUiElement screenRuntime;

protected override void Initialize()
{
    Gum.Initialize(this, "GumProject/GumProject.gumx");
    Gum.LoadAnimations();

    var screen = ObjectFinder.Self.GumProjectSave.Screens.First();
    screenRuntime = screen.ToGraphicalUiElement();
    screenRuntime.AddToRoot();

    base.Initialize();
}

protected override void Update(GameTime gameTime)
{
    Gum.Update(gameTime);

    var animation = screenRuntime.Animations[0];
    animation.ApplyAtTimeTo(gameTime.TotalGameTime.TotalSeconds, screenRuntime);

    base.Update(gameTime);
}

Last updated

Was this helpful?