Sprite Class

The basic object that is rendered to the game screen.

Constructor

Sprite ( bitmap )

Parameters:

  • bitmap Bitmap

    The image for the sprite

Item Index

Methods Properties

Methods

addChild ( child ) Object

Adds a child to the container.

Parameters:

  • child Object

    The child to add

Returns:

Object:
The child that was added

addChildAt ( child  index ) Object

Adds a child to the container at a specified index.

Parameters:

  • child Object

    The child to add

  • index Number

    The index to place the child in

Returns:

Object:
The child that was added

getBlendColor () Array

Gets the blend color for the sprite.

Returns:

Array:
The blend color [r, g, b, a]

getColorTone () Array

Gets the color tone for the sprite.

Returns:

Array:
The color tone [r, g, b, gray]

move ( x , y )

Sets the x and y at once.

Parameters:

  • x Number

    The x coordinate of the sprite

  • y Number

    The y coordinate of the sprite

removeChild ( child ) Object

Removes a child from the container.

Parameters:

  • child Object

    The child to remove

Returns:

Object:
The child that was removed

removeChildAt ( index ) Object

Removes a child from the specified index position.

Parameters:

  • index Number

    The index to get the child from

Returns:

Object:
The child that was removed

setBlendColor ( color )

Sets the blend color for the sprite.

Parameters:

  • color Array

    The blend color [r, g, b, a]

setColorTone ( tone )

Sets the color tone for the sprite.

Parameters:

  • tone Array

    The color tone [r, g, b, gray]

setFrame ( x , y , width , height )

Sets the rectagle of the bitmap that the sprite displays.

Parameters:

  • x Number

    The x coordinate of the frame

  • y Number

    The y coordinate of the frame

  • width Number

    The width of the frame

  • height Number

    The height of the frame

update ()

Updates the sprite for each frame.

Properties

anchor Point

The origin point of the sprite. (0,0) to (1,1).

bitmap Bitmap

The image for the sprite.

blendMode Number

The blend mode to be applied to the sprite.

children Array

[read-only] The array of children of the sprite.

filters Array

Sets the filters for the sprite.

height Number

The height of the sprite without the scale.

opacity Number

The opacity of the sprite (0 to 255).

parent Object

[read-only] The object that contains the sprite.

rotation Number

The rotation of the sprite in radians.

scale Point

The scale factor of the sprite.

visible Boolean

The visibility of the sprite.

width Number

The width of the sprite without the scale.

x Number

The x coordinate of the sprite.

y Number

The y coordinate of the sprite.