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. |
Extends
Members
-
finished :boolean
-
Read-only attributes that specifies whether the current animation has finished playing or not.
Type:
- boolean
-
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. -
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. -
destroy()
-
Destroy the component and its objects.
-
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. -
getAlpha() → {float}
-
Retrieve the transparency value of the sprite.
Returns:
Current transparency value.- Type
- float
-
getCurrentAnim() → {string}
-
Get the current animation being played.
Returns:
The name of the current animation.- Type
- string
-
getHeight() → {int}
-
Retrieve the height of a frame of the spritesheet.
Returns:
The actual height of a frame.- Type
- int
-
getOriginalHeight() → {int}
-
Retrieve the height of a frame before it was resized.
Returns:
The height of a frame before resizing.- Type
- int
-
getOriginalWidth() → {int}
-
Retrieve the height of a frame before it was resized.
Returns:
The width of a frame before resizing.- Type
- int
-
getWidth() → {int}
-
Retrieve the height of a frame of the spritesheet.
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. -
setAlpha(pNewAlpha)
-
Set the transparency of the sprite.
Parameters:
Name Type Description pNewAlpha
float New transparency value desired. -
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. -
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. -
stop()
-
Stop the animation.