How do I check if one or more tiles are overlapped ?

Get help using Construct 2

Post » Mon Nov 10, 2014 3:45 pm

How do I check if one or more tiles from a TileMap are overlapped by a sprite ?

I need to know in order to make this.
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Mon Nov 10, 2014 6:00 pm

You can loop through the x and y width and height of the tilemap and compare if they are overlapped.


for x in (tilemap.width / tilesize)
for y in tilemap.height/ tilesize)
tilemap.tileat(x, y) is overlapping sprite -> do actions

But with your example picture you are going to have to draw the colission box of that circle as an oval, if you are intending for the center part to count as "not touching"

another approach might be to draw the circle as a series of small sprites if you run into issues
B
87
S
44
G
16
Posts: 1,002
Reputation: 17,932


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests