Snap to snap a sprite/actor into one spot

Get help using Construct 2

Post » Mon Mar 23, 2015 3:08 pm

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!

Image
B
4
Posts: 19
Reputation: 238

Post » Mon Mar 23, 2015 3:40 pm

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.

Image
(The second condition is "System: Compare two values")
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,070

Post » Mon Mar 23, 2015 3:43 pm

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! :)
B
45
S
16
G
9
Posts: 1,096
Reputation: 11,138

Post » Mon Mar 23, 2015 4:22 pm

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

Image
B
4
Posts: 19
Reputation: 238

Post » Mon Mar 23, 2015 5:11 pm

You need to put the two conditions into the same event.
jigsaw_snap.capx (r200)
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,070


Return to How do I....?

Who is online

Users browsing this forum: Biim, Rudi55 and 29 guests