> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/gum/animations/setting-gum-animationchain-achx-in-code.md).

# Setting Gum Animationchain Achx in Code

### Introduction

Gum objects support playing .achx animations. This enables the use of the familiar AnimationEditor to create texture-based animations for Gum objects. Note that AnimationChain animations are used to change texture or texture coordinates. These are typically used for animated characters in 2D games. AnimationChain animations cannot change the size, orientation, or other common Gum properties.

### Note About Glue Version

Glue Version 12 introduces automatic calling of AnimateSelf on the top-level Gum screen. If your Glue project is using an earlier version than version 12, you will need to explicitly add the following to your CustomActivity:

```
GumScreen.AnimateSelf();
```

For more information on Glue versions, see the [gluj/glux page](/flatredball/glue-reference/glujglux.md).

### Setting Animations

For this example we will assume a Sprite named SpriteInstance.

![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-18aa6eb837ca579a9305f4d74be8aed4d4e257f8%2F2022-02-img_621bdf9420500.png?alt=media)

This Sprite is contained in a page named MainMenuGum which is assumed to be inside a FlatRedBall Screen named MainMenu.

![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-a3b16abe0bab334410e2e1766c48c80745486586%2F2022-02-img_621bdfc9e687d.png?alt=media)

We can set the Sprite to be animated using the following code in CustomInitialize:

```
var gumSprite = GumScreen.SpriteInstance;

gumSprite.Animate = true;
gumSprite.CurrentChainName = "CharacterWalkRight";
// The SourceFile property is a Texture2D, but we can also set it to
// a file path which will resolve to an animation using the SetProperty method.
gumSprite.SetProperty("SourceFile", "../Screens/MainMenu/PlatformerAnimations.achx");
gumSprite.TextureAddress = Gum.Managers.TextureAddress.Custom;
```

The Gum Sprite now animates when running the game.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-a9ce95b5a1bb202fbb0962d4ff4985034f95ed3e%2F2022-02-27_13-39-06.gif?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/flatredball/gum/animations/setting-gum-animationchain-achx-in-code.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
