new SpriteRendererComponent(pImage, pWidth, pHeight, pOwner)
The sprite renderer component is used to associate an image to a game object.
Parameters:
Name | Type | Description |
---|---|---|
pImage |
FM.ImageAsset | Image to use for rendering. |
pWidth |
int | Width of the sprite. |
pHeight |
int | Height of the sprite. |
pOwner |
FM.GameObject | The game object that owns this component. |
Extends
Members
-
name :FM.ComponentTypes
-
Component's name.
Type:
- Inherited From:
- Source:
-
offset :FM.Vector
-
Offset in case the image width is greater than the sprite.
Type:
-
owner :FM.GameObject
-
Component's owner.
Type:
- Inherited From:
- Source:
Methods
-
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 Position of the sprite to render. -
getAlpha() → {float}
-
Retrieve the transparency value of the sprite.
Returns:
Current transparency value.- Type
- float
-
getHeight() → {int}
-
Retrieve the height of the sprite.
Returns:
The actual height of the sprite.- Type
- int
-
getOriginalHeight() → {int}
-
Retrieve the height of a frame before it was resized.
Returns:
The height of the sprite before resizing.- Type
- int
-
getOriginalWidth() → {int}
-
Retrieve the height of a frame before it was resized.
Returns:
The width of the sprite before resizing.- Type
- int
-
getWidth() → {int}
-
Retrieve the width of the sprite.
Returns:
The actual width of the sprite.- Type
- int
-
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. -
setImage(pImage, pWidth, pHeight)
-
Set a new image.
Parameters:
Name Type Description pImage
FM.ImageAsset The new image of the sprite. pWidth
int The width of the sprite. pHeight
int The 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
int New width of the sprite.