Jump to content

Handle Dragging Sprite as Child of another Sprite


Recommended Posts

Hello all :)

I am pretty new to Phaser. Now I am testing to create drag and drop shape game.

I use this code :

var background = game.add.sprite(0,	0, 'atlas', 'background.png');
var shape = game.add.sprite(0, 0, 'atlas_test');
shape.frameName = 'ellipse.png' ;

shape.inputEnabled = true;

In short, this works fine, I drag with my mouse, and it follows my mouse pointer location. But problem happens when I add this :


When I add the draggable shape into background, somehow the draggable shape is several x and y away from the actual mouse pointer. Like, the shape is 'late'.

I wonder if the shape is following the background viewport since background is the parent.


Initially, my pointer on the center of this ellipse, then I drag to northeast, the shape follows the pointer but kind of late.

I wonder if is there any lead I can look upon, I need to persist shape as child of background, with normal drag as if the shape is not a of anyone's children.


Thank you.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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