Skip to main content
aidans35222432
Participant
November 17, 2017
Answered

Drag and drop smoothly Animate CC Canvas

  • November 17, 2017
  • 1 reply
  • 2166 views

I am using Animate CC, Canvas, I'm trying to drag my background scene along the X axis, the code I have so far is

this.scene.addEventListener("pressmove", dragMe.bind(this));  function dragMe (evt) { this.addChild(evt.currentTarget); var p = this.globalToLocal(evt.stageX, evt.stageY); evt.currentTarget.x = p.x; }

However each time I drag the background it snaps the image to the mouse (depending on where the axis - rotation point - is placed in Animate CC). This makes for an unsmooth drag, I would like something more like a touch screen interaction where I can just keep dragging/swiping it along.

I can't seem to find a solution anywhere for this.

Thanks in advance.

This topic has been closed for replies.
Correct answer Joseph Labrecque

Yes - by default, the x and y are calculated from teh registration point.

Have a look at the following example as it seems to accomplish what you are looking to do:

Draggable Canvas - JSFiddle

1 reply

Joseph Labrecque
Community Expert
Joseph LabrecqueCommunity ExpertCorrect answer
Community Expert
November 17, 2017

Yes - by default, the x and y are calculated from teh registration point.

Have a look at the following example as it seems to accomplish what you are looking to do:

Draggable Canvas - JSFiddle

aidans35222432
Participant
November 20, 2017

Wow! Yes!!! This is exactly what I was looking for, that's perfect thanks! I knew there had to be a way.