Drag and Drop Snap to Grid?

Get help using Construct 2

Post » Sat Mar 11, 2017 4:25 pm

So just as the title says how do i do that?
B
5
S
1
Posts: 7
Reputation: 341

Post » Sat Mar 11, 2017 4:49 pm

In your layout or on the game screen?

You can set the grid in the layout in the view settings. Hit enter key after changing the setting and hit show grid.

If you mean you want a snap to grid in your game then you need a sprite to use as a cursor set to the size of a grid square you want and you will need to check the mouse X and Y to see if it has moved left, right, up or down from the old location and then move your sprite used for a cursor the amount of change you want for the grid.
Banned User
B
28
S
7
G
58
Posts: 1,229
Reputation: 34,825

Post » Sat Mar 11, 2017 4:52 pm

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Mar 11, 2017 4:59 pm

@Aliigames

Global number GridSize is 32
Sprite:DragDrop is dragging -> Sprite: Set position to (round(Sprite.X/GridSize)*GridSize, round(Sprite.Y/GridSize)*GridSize)
Find all the Construct 2 games that were on Steam Greenlight here
B
35
S
9
G
7
Posts: 468
Reputation: 6,866

Post » Tue Nov 14, 2017 1:43 pm

OddConfection wrote:@Aliigames

Global number GridSize is 32
Sprite:DragDrop is dragging -> Sprite: Set position to (round(Sprite.X/GridSize)*GridSize, round(Sprite.Y/GridSize)*GridSize)


Thanks man thats what i was looking for...
B
14
S
3
G
1
Posts: 11
Reputation: 1,276

Post » Wed Nov 15, 2017 5:20 am

The perfect way is here ;)
B
52
S
24
G
46
Posts: 132
Reputation: 27,279

Post » Wed Nov 15, 2017 9:51 am

paradine wrote:The perfect way is here ;)


Apart from grid lines (which in most games you don't want) and separate variables for X and Y grid sizes, how is that functionally any different than what I posted? What makes it worth spending £1.99 for something so simple?

Just in case anyone wants different X and Y grid sizes, e.g. for isometric, then here is the updated version:
Global variable number GridSizeX is 64
Global variable number GridSizeY is 32
Sprite:DragDrop is dragging -> Sprite: Set position to (round(Sprite.X/GridSizeX)*GridSizeX, round(Sprite.Y/GridSizeY)*GridSizeY)
Find all the Construct 2 games that were on Steam Greenlight here
B
35
S
9
G
7
Posts: 468
Reputation: 6,866


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 31 guests