Sign in to follow this  

Drag from point which was clicked

Recommended Posts

the reason why bunny pops to cursor position is bunny's anchor point. You need to store offset and use it while dragging bunny

function onDragStart(event) {
    // store a reference to the data
    // the reason for this is because of multitouch
    // we want to track the movement of this particular touch =;
    this.alpha = 0.5;
    this.dragging = true;
     this.offX = this.x -;
     this.offY = this.y -;
function onDragMove() {
    if (this.dragging) {
        var newPosition =;
        this.x = newPosition.x + this.offX;
        this.y = newPosition.y + this.offY;


Share this post

Link to post
Share on other sites

I still couldn't get this to work the way I want. It would also be great if some of the examples could be in TypeScript. I think my issues might be around that and the 'this' context with callbacks.

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

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.