How do I make an object snap to grid at nearest 32x32 x, y

Get help using Construct 2

Post » Sun Nov 06, 2016 10:28 pm

I need to make an object snap to the grid at the nearest (32, 32) when it is created (during the game).
B
14
S
8
Posts: 12
Reputation: 1,338

Post » Sun Nov 06, 2016 10:39 pm

Is the object created INGAME by the player or in the creator?

"Pick nearest" is a common condition.

You select the object type ("Grid" here I guess) and input the position you want to test (here mouse.x and mouse.y).
This will pick the nearest instance of the Grid object to your mouse cursor.

For drag/drop mechanics I suggest you to check the how do I FAQ, I think there are a few examples of drag/drop listed in there.

The "snap to grid" effect is achieved when you drop an object by spawning it in the middle of the current cell instead of the mouse position where it was droped.
It depends a great deal on how you setup your grid.
B
21
S
9
G
8
Posts: 188
Reputation: 6,069

Post » Sun Nov 06, 2016 11:11 pm

The object is created in-game by the player. I need the object that ,is created, to instantly move to the nearest 32, 32 (x, y) like when "snap to grid" is enabled on Construct 2.
B
14
S
8
Posts: 12
Reputation: 1,338

Post » Sun Nov 06, 2016 11:40 pm

GameOverBeast wrote:The object is created in-game by the player


something like?

Image

SpriteMaps
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Tue Nov 08, 2016 6:14 am

Thanks so much korbaach, you just helped to solve many of the problems I have been having.
B
14
S
8
Posts: 12
Reputation: 1,338


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests