Sprite Class
The basic object that is rendered to the game screen.
Constructor
Sprite ( bitmap )
Parameters:
-
bitmap
BitmapThe image for the sprite
Item Index
Methods PropertiesMethods
addChild ( child ) Object
Adds a child to the container.
Parameters:
-
child
ObjectThe 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
ObjectThe child to add
-
index
NumberThe 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
NumberThe x coordinate of the sprite
-
y
NumberThe y coordinate of the sprite
removeChild ( child ) Object
Removes a child from the container.
Parameters:
-
child
ObjectThe child to remove
Returns:
Object:
The child that was removed
removeChildAt ( index ) Object
Removes a child from the specified index position.
Parameters:
-
index
NumberThe index to get the child from
Returns:
Object:
The child that was removed
setBlendColor ( color )
Sets the blend color for the sprite.
Parameters:
-
color
ArrayThe blend color [r, g, b, a]
setColorTone ( tone )
Sets the color tone for the sprite.
Parameters:
-
tone
ArrayThe color tone [r, g, b, gray]
setFrame ( x , y , width , height )
Sets the rectagle of the bitmap that the sprite displays.
Parameters:
-
x
NumberThe x coordinate of the frame
-
y
NumberThe y coordinate of the frame
-
width
NumberThe width of the frame
-
height
NumberThe 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.