API Document Index



Class me.SpriteObject


Extends me.Rect.

Defined in: <build/melonJS-0.9.3.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
me.SpriteObject(x, y, image, spritewidth, spriteheigth)
A Simple object to display a sprite on screen.
Field Summary
Field Attributes Field Name and Description
 
a flag that can prevent the object to be destroyed
if set to false, the objet won't be destroy when calling me.game.remove(obj)
default value : true
 
the visible state of the object
default value : true
Fields borrowed from class me.Rect:
bottom, height, left, pos, right, top, width
Method Summary
Method Attributes Method Name and Description
 
draw(context)
object draw
not to be called by the end user
called by the game manager on each game loop
 
flicker(duration, callback)
make the object flicker
 
flipX(flip)
Flip object on horizontal axis
 
flipY(flip)
Flip object on vertical axis
 
return the flickering state of the object
 
OnDestroy Notification function
Called by engine before deleting the object
 
resize(ratio)
Resize the object around his center
Note : This won't resize the corresponding collision box
 
specify a transparent color
 
sprite update
not to be called by the end user
called by the game manager on each game loop
Methods borrowed from class me.Rect:
contains, containsPoint, getRect, overlaps, set, union, within
Class Detail
me.SpriteObject(x, y, image, spritewidth, spriteheigth)
A Simple object to display a sprite on screen.
// create a static Sprite Object
mySprite = new SpriteObject (100, 100, me.loader.getImage("mySpriteImage"));
Parameters:
{int} x
the x coordinates of the sprite object
{int} y
the y coordinates of the sprite object
{me.loader#getImage} image
reference to the Sprite Image
{int} spritewidth Optional
sprite width
{int} spriteheigth Optional
sprite height
Field Detail
{Boolean} autodestroy
a flag that can prevent the object to be destroyed
if set to false, the objet won't be destroy when calling me.game.remove(obj)
default value : true

{Boolean} visible
the visible state of the object
default value : true
Method Detail
draw(context)
object draw
not to be called by the end user
called by the game manager on each game loop
Parameters:
{Context2d} context
2d Context on which draw our object

flicker(duration, callback)
make the object flicker
// make the object flicker for 60 frame
// and then remove it
this.flicker(60, function()
{
   me.game.remove(this);
});
Parameters:
{Int} duration
{Function} callback

flipX(flip)
Flip object on horizontal axis
Parameters:
{Boolean} flip
enable/disable flip

flipY(flip)
Flip object on vertical axis
Parameters:
{Boolean} flip
enable/disable flip

isFlickering()
return the flickering state of the object
Returns:
Boolean

onDestroyEvent()
OnDestroy Notification function
Called by engine before deleting the object

resize(ratio)
Resize the object around his center
Note : This won't resize the corresponding collision box
Parameters:
{Boolean} ratio
scaling ratio

setTransparency(color)
specify a transparent color
Parameters:
{String} color
color key in rgb format (rrggb or #rrggb)

update()
sprite update
not to be called by the end user
called by the game manager on each game loop
Returns:
false

Documentation generated by JsDoc Toolkit 2.4.0 on Tue May 01 2012 12:00:50 GMT+0800 (CST)