AnimationFrame
Introduction
Creating an AnimationFrame
Creating an AnimationFrame in Code
void CustomInitialize()
{
// This code assumes SpriteInstance is a valid Sprite,
// TextureFile is a valid Texture2D.
AnimationChain animationChain = new AnimationChain();
AnimationFrame animationFrame = new AnimationFrame();
animationFrame.Texture = TextureFile;
// TextureCoordinates are normalized. In other
// words:
// * 0 represents the left or top edge of the texture
// * 1 represents the right or bottom edge of the texture
animationFrame.LeftCoordinate = 0;
animationFrame.RightCoordinate = 1;
animationFrame.TopCoordinate = 0;
// A value of .5 means halfway down the texture.
// By setting the BottomCoordinate to .5f, only the top
// half of the Sprite gets drawn.
animationFrame.BottomCoordinate = .5f;
animationChain.Add(animationFrame);
SpriteInstance.SetAnimationChain(animationChain);
SpriteInstance.UpdateToCurrentAnimationFrame();
}
FrameLength
Last updated
Was this helpful?