Skip to main content
Known Participant
March 30, 2015
Question

Drag and Drop Shapes that snap back to its original position, if it is placed in the correct shape it stays there. What code can I use? PLEASE HELP!

  • March 30, 2015
  • 1 reply
  • 210 views

I need the code for this, how could I possible do this?

I'm a begginer and I am very interested as to how I can create this.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
March 31, 2015

using the same initialization code shown in your previous post, use:

// in your drop listener function

if(square.hitTestObject(whatever)){

square.x=whatever.x;

square.y=whatever.y;

} else {

square.x=square.initX;

square.y=square.initY;

}