Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
//Handle dragging from within a scaled parent
//Currently just drags from center of sprite
function scaledDrag(sprite) {
sprite.inputEnabled = true;
sprite.input.enableDrag(); (sprite, pointer, x, y) {
var pos =, pointer);
if (sprite.hitArea) {
sprite.x = pos.x - sprite.hitArea.width/2;
sprite.y = pos.y - sprite.hitArea.height/2;
} else {
sprite.x = pos.x - sprite.width/2;
sprite.y = pos.y - sprite.height/2;
}, sprite);
return sprite;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.