Sprite Sheet Controller

Sprite Sheet Animation Controller

This controller is used to control or animate the spriteIndex property on a Sprite Sheet Render at a certain framerate. Select the sprite sheet renderer that you want to animate and define all of the animations by name. Animations can only have a start and end value so frames in the sprite sheet need to be in the correct sequential order.



  • currentAnimationReference - A property reference pointing to another location to read in the current animation. Can be used to contrl the current animation from a property on a Data Container.
  • currentAnimationDurationReference - A property reference point to another location to read in the current animation's duration in milliseconds
  • currentAnimationStartTimeReference - A property reference point to another location to read in the intended start time of the current animation. This can be used to make sure that animations don't "lag" behind their actions if framerate is low.
  • currentFrameReference - A property reference used to set the current frame index of the running animation as it cycles through the start and end frame values.
  • loop - will put the current animation in an endless loop unless explicitly changed by setting the currentAnimationName
  • paused - used to pause any active animation
  • spriteSheetReference - A property reference pointing to the location of the Sprite Sheet Renderer that is controlled by this animation controller.
  • currentAnimationName - The name of the current animation to run.

Setting The Default Animation


Check the box next to the animation that is the default animation

Using Different Sprite Sheets


Select the sprite sheet you want to use for each animation added. Multiple sprite sheets can be created on the same entity and swapped out based on the current animation.

Code Sample

var entity : IEntity = PBE.allocateEntity();

var divider : CellCountDivider = new CellCountDivider();
divider.xCount = 10;
divider.yCount = 2;

var sheet : SpriteSheetComponent = new SpriteSheetComponent();
sheet.fileName = "assets/imagesheet.png";
sheet.divider = divider;
entity.addComponent(sheet, "SpriteSheet");

var sheetRenderer : SpriteSheetRenderer = new SpriteSheetRenderer();
sheetRenderer.spriteSheet = sheet;
entity.addComponent(sheetRenderer, "SpriteSheetRenderer");

//Animate the spriteIndex property on the sprite sheet renderer
var sheetAnimator : AnimationController = new AnimationController();
sheetAnimator.spriteSheetReference = new PropertyReference("@SpriteSheetRenderer");
sheetAnimator.defaultAnimation = "Walk";

sheetAnimator.animations = new Dictionary();
sheetAnimator.animations["Walk"] = new AnimationControllerInfo();
sheetAnimator.animations["Walk"].frameRate = 24;
sheetAnimator.animations["Walk"].spriteSheet = sheet;
//If you don't set a custom list of frames the sprite sheet will be cycled from start to finish
//based on its total frame count
sheetAnimator.animations["Walk"].customFrames = true;
sheetAnimator.animations["Walk"].customFrameList = [0, 1, 2, 3, 4, 5, 7];

entity.addComponent(sheetAnimator, "SpriteSheetAnimations");

Follow Us For Updates