Sprite

Extends: AnimatedImage

Properties

  • spriteSheet (ifDraw2d) — roBitmap to pick cells from
  • cellWidth (integer) — Width of each animation cell in the sprite image in pixels
  • cellHeight (integer) — Height of each animation cell in the sprite image in pixels
  • animations (roAssociativeArray) — Lookup map of animation name -> SpriteAnimation object
  • activeAnimation (SpriteAnimation) — The current animation being played

Constructor

new Sprite( owner: GameEntity, spriteSheet: ifDraw2d, cellWidth: integer, cellHeight: integer, args?: roAssociativeArray, ): Sprite

Parameters

  • owner (GameEntity)
  • spriteSheet (ifDraw2d)
  • cellWidth (integer)
  • cellHeight (integer)
  • args (roAssociativeArray, optional, default: "{}")

Instance Methods

applyPreTranslation(x: float, y: float): void

Apply a pre-translation to set the pivot point for the sprite cell

Parameters

  • x (float)
  • y (float)

Returns

  • void

addAnimation( name: string, frameList: dynamic, frameRate: integer, playMode?: SpritePlayMode, ): BGE.SpriteAnimation

Parameters

  • name (string)
  • frameList (dynamic)
  • frameRate (integer)
  • playMode (SpritePlayMode, optional, default: "SpritePlayMode.Loop")

Returns

playAnimation(animationName: string): void

Play an animation from the set of animations in this SpriteSheet

Parameters

  • animationName (string)

Returns

  • void

getCellDrawIndex(): integer

protected

Returns

  • integer