Grid Based X,Y

Discussion and feedback on Construct 2

Post » Sun Oct 09, 2011 11:59 am

Hi there,
Is there any way to have the whole layout split into a grid with its own X and Y values? The grid would obviously be made of squares bigger than a single pixel.
B
40
S
8
G
6
Posts: 61
Reputation: 5,941

Post » Sun Oct 09, 2011 1:28 pm

Do you just want to show a grid, or display objects snapped to a grid?

Snapping to a grid is easy, just set every object's X and Y to:

round(Object.X / 32) * 32
round(Object.Y / 32) * 32

where 32 is the size of the grid cell.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Sun Oct 09, 2011 3:04 pm

Thanks!
Just another quick question, if the objects are snapped to a grid, if an object is one cell above another (say obj1.y=1 & obj2.y=2 on the grid) would they still be considered touching (for any collision events)?
B
40
S
8
G
6
Posts: 61
Reputation: 5,941

Post » Sun Oct 09, 2011 4:23 pm

I'm not sure, try it and see. You might want to compare positions directly instead of testing for collisions anyway.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests