Skip to main content
Known Participant
Jul 18, 2022 3:13 AM UTC
Answered

Snap to all targets (Drag and drop game Animate CC HTML5 Canvas)

Hi,

I created a drag and drop game in Animate CC with HTML5 canvas. How to make an object (red box) snaps to targets (white boxes)? It's not just snaps on correct target but also incorrect target, then shows response (correct or incorrect).

Best regard..

    This topic is closed to new replies. Start a new post to keep the conversation going.
    kglad
    kgladCorrect answer
    Community Expert
    Jul 18, 2022 2:44 PM UTC

    assuming all have the same center registration point and (target_mc is defined)

     

    this.redbox.x = this.redbox.target_mc.x;

    this.redbox.y = this.redbox.target_mc.y;

     

    1 reply

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    Jul 18, 2022 2:44 PM UTC

    assuming all have the same center registration point and (target_mc is defined)

     

    this.redbox.x = this.redbox.target_mc.x;

    this.redbox.y = this.redbox.target_mc.y;

     

    Translate