Sprite : GameObject
Sprite class creates game characters and manages their animation and movement.
Example
// create new layer this._sprite = new Sprite({ image : "app://sprite.png", frameWidth : 32, frameHeight : 32, x : System.width / 2, y : System.height / 2, }); // create new scane var level1 = new Scene(); // add layer to the scene level1.add(this._sprite);
Properties
-
defaults : Object
Sets default controls options.
-
frame : Integer
Get frame index.
-
frameHeight : Integer
Set frame height.
-
frameWidth : Integer
Set frame width.
-
height : Integer
Height of this object
-
image : Bitmap
Game object image.
-
name : String
Name of the game object.
-
options : Object
Position of navigation bar.
-
paint : Paint
Object used for final decoration.
-
scale : Float
Scale of the game object.
-
scaledHeight : Integer
Get scaled height of this object.
-
scaledWidth : Integer
Get scaled width of this object.
-
sequence : Array
Sequence of the frames.
-
this(options = {})
Construct of the object calls following method in order.
-
visible : Boolean
Visibility of game object. Default is set to visibility true.
-
width : Integer
Width of this object
-
x : Integer
X - coordinates of view's position.
-
y : Integer
Y - coordinates of view's position.
Methods
-
_setObject()
Object parameters if object has been changed.
-
afterInit
Method is executed after inititialization of this object
-
beforeInit
Method is executed before inititialiation of this object
-
draw(canvas,paint = null)
Method to defines what is done if onDraw event is called.
-
init() : Sprite
Init sprite object instance.
-
intersectsBounds(obj) : Boolean
Check intersects by object.
-
intersectsPoint(x, y) : Boolean
Check intersects by Location(x and y coordinate).
-
nextFrame(rewind = true)
Get next Frame.
-
prevFrame(rewind = true)
Get previous frame.
-
process()
Call on process handler if defined.
-
setDefaults
Method is setting default class values.
-
setOptions
Method is setting options passed as class parameters.
-
undefined(k,v)
Sspecial property executed when priperty is undefined. It can be that JSON format is in format "key" : "value".
Events
-
onProcess(sender) : Function
Event on process handler. It defines what suppose to be done on game process.