Class: AnimatedSpriteRendererComponent

AnimatedSpriteRendererComponent

FM.AnimatedSpriteRendererComponent

new AnimatedSpriteRendererComponent(pImage, pWidth, pHeight, pOwner)

The animated sprite renderer component is used for drawing sprites with animations, it requires a spritesheet.
Parameters:
Name Type Description
pImage FM.ImageAsset Image of the spritesheet.
pWidth int Width of a frame of the spritesheet.
pHeight int Height of a frame of the spritesheet.
pOwner FM.GameObject Game object owner of the component.
Author:
  • Simon Chauvin
Source:

Extends

Members

finished :boolean

Read-only attributes that specifies whether the current animation has finished playing or not.
Type:
  • boolean
Source:

name :FM.ComponentTypes

Component's name.
Type:
Inherited From:
Source:

owner :FM.GameObject

Component's owner.
Type:
Inherited From:
Source:

Methods

addAnimation(pName, pFrames, pFrameRate, pIsLooped)

Add an animation.
Parameters:
Name Type Description
pName string Name of the animation.
pFrames Array Frames of the animation.
pFrameRate int Speed of the animation.
pIsLooped boolean Whether the animation should loop or not.
Source:

changeSize(pFactor)

Change the size of the sprite. You will need to change the position of the spatial component of this game object if you need a resize from the center.
Parameters:
Name Type Description
pFactor float Factor by which the size will be changed.
Source:

destroy()

Destroy the component and its objects.
Source:

draw(bufferContext, newPosition)

Draw the sprite.
Parameters:
Name Type Description
bufferContext CanvasRenderingContext2D Context on which drawing is done.
newPosition FM.Vector The position of the object to draw.
Source:

getAlpha() → {float}

Retrieve the transparency value of the sprite.
Source:
Returns:
Current transparency value.
Type
float

getCurrentAnim() → {string}

Get the current animation being played.
Source:
Returns:
The name of the current animation.
Type
string

getHeight() → {int}

Retrieve the height of a frame of the spritesheet.
Source:
Returns:
The actual height of a frame.
Type
int

getOriginalHeight() → {int}

Retrieve the height of a frame before it was resized.
Source:
Returns:
The height of a frame before resizing.
Type
int

getOriginalWidth() → {int}

Retrieve the height of a frame before it was resized.
Source:
Returns:
The width of a frame before resizing.
Type
int

getWidth() → {int}

Retrieve the height of a frame of the spritesheet.
Source:
Returns:
The actual width of a frame.
Type
int

play(pAnimName)

Play the given animation.
Parameters:
Name Type Description
pAnimName string Name of the animation to be played.
Source:

setAlpha(pNewAlpha)

Set the transparency of the sprite.
Parameters:
Name Type Description
pNewAlpha float New transparency value desired.
Source:

setHeight(pNewHeight)

Set the height of the sprite. You will need to change the position of the spatial component of this game object if you need a resize from the center.
Parameters:
Name Type Description
pNewHeight float New height of the sprite.
Source:

setWidth(pNewWidth)

Set the width of the sprite. You will need to change the position of the spatial component of this game object if you need a resize from the center.
Parameters:
Name Type Description
pNewWidth float New width of the sprite.
Source:

stop()

Stop the animation.
Source: