Jump to content

Possible Bug Enabledrag and bringToTop

Pedro Alpera

Recommended Posts

I have seen a possible bug, when you set bringToTop to true in enableDrag:


enableDrag(false, true)


StopDrag event don´t work until you move the mouse.

In touch devices it´s not fired.


Example: I drag a sprite, then without moving the mouse I release the button, the event it is not fired, when I move the mouse again the event is fired.


I have made an example:



Example Code:

window.onload = function () {

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update});

var graphics;
var bmd;

function preload() {
game.load.image('block', 'assets/block.png');

function create() {


block = game.add.sprite(100, 100, 'block');
block1 = game.add.sprite(100, 300, 'block');

block.originX = block.x;
block.originY = block.y;
block1.originX = block1.x;
block1.originY = block1.y;

block.inputEnabled = true;
block1.inputEnabled = true;

block.input.enableDrag(false, false);
block1.input.enableDrag(false, true);

block.events.onDragStop.add(blockDragStop, this);
block1.events.onDragStop.add(blockDragStop, this);

// Text

var text1 = "input.enableDrag(false, false);";
var text2 = "input.enableDrag(false, true) - Not working";

var style = { font: "15px Arial", fill: "#ffffff", align: "left" };

var t1 = game.add.text(100, 210, text1, style);
var t2 = game.add.text(100, 410, text2, style);

function blockDragStop(item) {

game.add.tween(item).to({x: item.originX, y: item.originY }, 400, Phaser.Easing.Back.Out, true);


function update() {

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...