File: rendering\Components.js
/**
A component class that holds the graphical representation of the entity.
@class Sprite
@constructor
@param spriteSheetHandle {AssetHandle} Handle to the sprite sheet asset which has this entity's sprite.
@param spriteIndex {Number} The sprite's index in the sprite sheet's array of sprites.
@param zIndex {Number} The sprite's z-index describes the rendering order. Sprites with a higher z-index are rendered on top of sprites with a lower z-index.
*/
function Sprite(spriteSheetHandle, spriteIndex, zIndex){
this._spriteSheetHandle = spriteSheetHandle || null;
this._spriteIndex = spriteIndex || 0;
this._zIndex = (zIndex !== undefined) ? zIndex : Number.NEGATIVE_INFINITY;
}
Sprite.prototype = {
constructor : Sprite,
_componentIdentifier : 0,
/**
@method getSpriteSheetHandle
@return {AssetHandle} Direct reference to the asset handle to the sprite sheet this sprite is in.
*/
getSpriteSheetHandle : function(){
return this._spriteSheetHandle;
},
/**
@method setSpriteSheetHandle
@param spriteSheetHandle {AssetHandle} Handle to the sprite sheet this sprite is in.
*/
setSpriteSheetHandle : function(spriteSheetHandle){
this._spriteSheetHandle = spriteSheetHandle;
},
/**
@method getSpriteIndex
@return {Number} Index of this sprite in the sprite sheet.
*/
getSpriteIndex : function(){
return this._spriteIndex;
},
/**
@method setSpriteIndex
@param spriteIndex {Number} Index of this sprite in the sprite sheet.
*/
setSpriteIndex : function(spriteIndex){
this._spriteIndex = spriteIndex;
},
/**
@method getZIndex
@return {Number} The sprite's z-index, which describes the rendering order.
*/
getZIndex : function(){
return this._zIndex;
},
/**
@method setZIndex
@param zIndex {Number} The sprite's z-index, which describes the rendering order.
*/
setZIndex : function(zIndex){
this._zIndex = zIndex;
}
};