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