Snap to snap a sprite/actor into one spot

  • Trying to make my basic game idea work.

    It's a simple one scene layout. Background layer is an image with a cut out of an object (dinosaur). Top layer is the dinosaur cut out itself. I am wanting to be able to move the dinosaur into the 'cut-out' and have it snap into place, rendering it unmoveable. This is a very basic jigsaw-slide type game.

    The dinosaur top layer has a property of drag and drop. This of course moves the dinosaur around with the mouse but will not lock into place. Any ideas on how it's done?. Thanks!

  • Check the distance between the dragged sprite and its cutout and when it's within a certain distance then drop and position the sprite. The sprite and its cutout both have the origin point in the same place.

    (The second condition is "System: Compare two values")

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Simply do a check to make sure the dino is overlapping the black shape then Onrelease set the dino x,y to the black shape x,y.

    Edit: ninj'd!

  • Thanks for that, it does make sense just hard to work out when being so new. I tried what you said but it seems as soon as I click my mouse (to begin to drag) the dino automatically locks into the position chosen and nothing else happens. Not sure what I've done different.

    Cheers

  • You need to put the two conditions into the same event.

    jigsaw_snap.capx (r200)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)