Coganjen Posted February 28, 2017 Share Posted February 28, 2017 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; shape.input.enableDrag(); In short, this works fine, I drag with my mouse, and it follows my mouse pointer location. But problem happens when I add this : background.addChild(shape); 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 More sharing options...
Coganjen Posted March 1, 2017 Author Share Posted March 1, 2017 Hello, After surfing and checking more. I found the solution here. https://gist.github.com/markacola/3899cc02c8c4846bdb864b8d9189cb80 This may help people who happens to have same problem with me. Thank you Link to comment Share on other sites More sharing options...
Recommended Posts