diff --git a/examples/outofbounds.php b/examples/outofbounds.php
new file mode 100644
index 000000000..c40f05205
--- /dev/null
+++ b/examples/outofbounds.php
@@ -0,0 +1,62 @@
+
+
+
+ phaser.js - a new beginning
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/core/Group.js b/src/core/Group.js
index 67b07bdad..5df05db7d 100644
--- a/src/core/Group.js
+++ b/src/core/Group.js
@@ -32,6 +32,7 @@ Phaser.Group.prototype = {
if (child.group !== this)
{
child.group = this;
+ child.events.onAddedToGroup.dispatch(child, this);
this._container.addChild(child);
}
@@ -44,6 +45,7 @@ Phaser.Group.prototype = {
if (child.group !== this)
{
child.group = this;
+ child.events.onAddedToGroup.dispatch(child, this);
this._container.addChildAt(child, index);
}
@@ -61,6 +63,7 @@ Phaser.Group.prototype = {
var child = new Phaser.Sprite(this.game, x, y, key, frame);
child.group = this;
+ child.events.onAddedToGroup.dispatch(child, this);
this._container.addChild(child);
return child;
@@ -186,11 +189,13 @@ Phaser.Group.prototype = {
{
if (newChild.parent != undefined)
{
+ newChild.events.onRemovedFromGroup.dispatch(newChild, this);
newChild.parent.removeChild(newChild);
}
this._container.removeChild(oldChild);
this._container.addChildAt(newChild, index);
+ newChild.events.onAddedToGroup.dispatch(newChild, this);
}
},
@@ -600,6 +605,7 @@ Phaser.Group.prototype = {
remove: function (child) {
+ child.events.onRemovedFromGroup.dispatch(child, this);
this._container.removeChild(child);
},
@@ -608,6 +614,7 @@ Phaser.Group.prototype = {
do
{
+ this._container.children[0].events.onRemovedFromGroup.dispatch(this._container.children[0], this);
this._container.removeChild(this._container.children[0]);
}
while (this._container.children.length > 0);
@@ -624,6 +631,7 @@ Phaser.Group.prototype = {
for (var i = startIndex; i < endIndex; i++)
{
var child = this._container.children[i];
+ child.events.onRemovedFromGroup.dispatch(child, this);
this._container.removeChild(child);
}
diff --git a/src/gameobjects/Sprite.js b/src/gameobjects/Sprite.js
index ac9d71503..72bfb5f17 100644
--- a/src/gameobjects/Sprite.js
+++ b/src/gameobjects/Sprite.js
@@ -142,6 +142,8 @@ Phaser.Sprite = function (game, x, y, key, frame) {
// Set-up the physics body
this.body = new Phaser.Physics.Arcade.Body(this);
+ this._outOfBoundsFired = false;
+
};
// Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly)
@@ -270,9 +272,14 @@ Phaser.Sprite.prototype.update = function() {
}
-Phaser.Sprite.prototype.postUpdate = function() {
+Phaser.Sprite.prototype.reset = function(x, y) {
- this.body.postUpdate();
+ this.x = x;
+ this.y = y;
+ this.alive = true;
+ this.exists = true;
+ this.visible = true;
+ this._outOfBoundsFired = false;
}
@@ -299,6 +306,13 @@ Phaser.Sprite.prototype.updateBounds = function() {
this._cache.boundsX = this._cache.x;
this._cache.boundsY = this._cache.y;
+ // Check world bounds
+ if (this._outOfBoundsFired == false && Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, 100) == false)
+ {
+ this.events.onOutOfBounds.dispatch(this);
+ this._outOfBoundsFired = true;
+ }
+
}
Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) {
diff --git a/src/input/Input.js b/src/input/Input.js
index 91e520ca0..3042e4385 100644
--- a/src/input/Input.js
+++ b/src/input/Input.js
@@ -381,7 +381,7 @@ Phaser.Input.prototype = {
}
this.currentPointers = 0;
- // this.game.stage.canvas.style.cursor = "default";
+ this.game.stage.canvas.style.cursor = "default";
if (hard == true)
{
diff --git a/src/input/Pointer.js b/src/input/Pointer.js
index a388d486b..a8dea7ca0 100644
--- a/src/input/Pointer.js
+++ b/src/input/Pointer.js
@@ -240,10 +240,10 @@ Phaser.Pointer.prototype = {
if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
{
- //this.game.input.x = this.x * this.game.input.scale.x;
- //this.game.input.y = this.y * this.game.input.scale.y;
- this.game.input.x = this.x;
- this.game.input.y = this.y;
+ this.game.input.x = this.x * this.game.input.scale.x;
+ this.game.input.y = this.y * this.game.input.scale.y;
+ // this.game.input.x = this.x;
+ // this.game.input.y = this.y;
this.game.input.position.setTo(this.x, this.y);
this.game.input.onDown.dispatch(this);
this.game.input.resetSpeed(this.x, this.y);