Added Group IDs and references to Sprites, Group sorting, z-index values and child swapping. Also added all of the drag and bounds methods to Input.

This commit is contained in:
Richard Davey
2013-06-02 03:47:54 +01:00
parent 59f7a59312
commit 49fe5ee65f
22 changed files with 1891 additions and 237 deletions
+10 -10
View File
@@ -9,6 +9,16 @@ module Phaser {
*/
game: Game;
/**
* The type of game object.
*/
type: number;
/**
* The ID of the Group this Sprite belongs to.
*/
group: Group;
/**
* x value of the object.
*/
@@ -24,16 +34,6 @@ module Phaser {
*/
z: number;
/**
* The type of game object.
*/
type: number;
/**
* Reference to the Renderer.renderSprite method. Can be overriden by custom classes.
*/
//render;
/**
* Controls if both <code>update</code> and render are called by the core game loop.
*/
+22 -2
View File
@@ -41,7 +41,8 @@ module Phaser {
this.x = x;
this.y = y;
this.z = 0; // not used yet
this.z = -1;
this.group = null;
// If a texture has been given the body will be set to that size, otherwise 16x16
this.body = new Phaser.Physics.Body(this, bodyType);
@@ -69,6 +70,11 @@ module Phaser {
*/
public type: number;
/**
* The Group this Sprite belongs to.
*/
public group: Group;
/**
* Controls if both <code>update</code> and render are called by the core game loop.
*/
@@ -310,6 +316,7 @@ module Phaser {
* Clean up memory.
*/
public destroy() {
}
/**
@@ -319,9 +326,18 @@ module Phaser {
* like to animate an effect or whatever, you should override this,
* setting only alive to false, and leaving exists true.
*/
public kill() {
public kill(removeFromGroup:bool = false) {
this.alive = false;
this.exists = false;
if (removeFromGroup && this.group)
{
this.group.remove(this);
}
this.events.onKilled.dispatch(this);
}
/**
@@ -329,8 +345,12 @@ module Phaser {
* In practice, this is most often called by <code>Object.reset()</code>.
*/
public revive() {
this.alive = true;
this.exists = true;
this.events.onRevived.dispatch(this);
}
}