diff --git a/examples/bring to top.php b/examples/bring to top.php new file mode 100644 index 00000000..bbf52967 --- /dev/null +++ b/examples/bring to top.php @@ -0,0 +1,54 @@ + + + + phaser.js - a new beginning + + + + + + + + \ No newline at end of file diff --git a/src/core/World.js b/src/core/World.js index da2b1c51..5d29dcdf 100644 --- a/src/core/World.js +++ b/src/core/World.js @@ -91,6 +91,17 @@ Phaser.World.prototype = { }, + bringToTop: function (child) { + + if (child !== this._stage.last) + { + this.swapChildren(child, this._stage.last); + } + + return child; + + }, + swapChildren: function (child1, child2) { if (child1 === child2 || !child1.parent || !child2.parent) diff --git a/src/gameobjects/Sprite.js b/src/gameobjects/Sprite.js index 863abd85..ac9d7150 100644 --- a/src/gameobjects/Sprite.js +++ b/src/gameobjects/Sprite.js @@ -319,6 +319,19 @@ Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, x, y) { } +Phaser.Sprite.prototype.bringToTop = function() { + + if (this.group) + { + this.group.bringToTop(this); + } + else + { + this.game.world.bringToTop(this); + } + +} + Phaser.Sprite.prototype.getBounds = function(rect) { rect = rect || new Phaser.Rectangle; diff --git a/src/input/InputHandler.js b/src/input/InputHandler.js index c6a31d3f..e289a02d 100644 --- a/src/input/InputHandler.js +++ b/src/input/InputHandler.js @@ -672,7 +672,7 @@ Phaser.InputHandler.prototype = { if (this.dragFromCenter) { - this.sprite.transform.centerOn(pointer.worldX, pointer.worldY); + // this.sprite.transform.centerOn(pointer.worldX, pointer.worldY); this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y); } else