AGK for Pascal
TAgkSprite.SetAnimation Method

Initialises the sprite animation with frames from its assigned image, based on a frame width and frame height.

procedure SetAnimation(const FrameWidth: Integer; const FrameHeight: Integer; const FrameCount: Integer);
const FrameWidth: Integer 
The width of the frames in pixels on the image. 
const FrameHeight: Integer 
The height of the frames in pixels on the image. 
const FrameCount: Integer 
The number of frames the sprite should attempt to retrive from the image. 

The sprite will use the frame width and frame height to extract images of that size from its assigned image beginning in the top left corner and moving from left to right. When it reaches the right hand side of the image it will begin again one row down, moving from left to right again until the frame count is reached or it runs out of space on the image to look for frames. Storing an animation image on an atlas texture is supported. 

This is the preferred method of assigning an animation to a sprite as it avoids expensive image changes during rendering. However if all your animation frames are separate images you can use AddAnimationFrame to add frames from images individually.

Copyright (c) 2012. All rights reserved.