Class enchant.Sprite
Class which can display images.
- Defined in: enchant.js
- Extends enchant.Entity
Constructor Attributes | Constructor Name and Description |
---|---|
enchant.Sprite(width, height)
|
Field Attributes | Field Name and Description |
---|---|
Index of the frame to be displayed.
|
|
Image displayed in the Sprite.
|
- Fields borrowed from class enchant.Entity:
- backgroundColor, buttonMode, buttonPressed, compositeOperation, debugColor, height, opacity, originX, originY, rotation, scaleX, scaleY, touchEnabled, visible, width
- Fields borrowed from class enchant.Node:
- age, parentNode, scene, x, y
Method Summary
- Methods borrowed from class enchant.Entity:
- disableCollection
- enableCollection
- intersect
- rotate
- scale
- within
- Methods borrowed from class enchant.Node:
- moveBy
- moveTo
- Methods borrowed from class enchant.EventTarget:
- addEventListener
- clearEventListener
- dispatchEvent
- on
- removeEventListener
Class Detail
enchant.Sprite(width, height)
var bear = new Sprite(32, 32); bear.image = core.assets['chara1.gif'];
- Parameters:
- {Number} width
- Sprite width.
- {Number} height
- Sprite height.
Field Detail
{Number|Array}
frame
Index of the frame to be displayed.
Frames with the same width and height as Sprite will be arrayed from upper left corner of the
enchant.Sprite#image image. When a sequence of numbers is provided, the displayed frame
will switch automatically. At the end of the array the sequence will restart. By setting
a value within the sequence to null, the frame switching is stopped.
var sprite = new Sprite(32, 32); sprite.frame = [0, 1, 0, 2] //-> 0, 1, 0, 2, 0, 1, 0, 2,.. sprite.frame = [0, 1, 0, 2, null] //-> 0, 1, 0, 2, (2, 2,.. :stop)
{enchant.Surface}
image
Image displayed in the Sprite.