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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.