How do I check if a tile is overlapped or empty(was erased)?

Get help using Construct 2

Post » Sun Jan 31, 2016 1:42 pm

I'm using tilemap to create sprites when the player touch it and I need to verify if another sprite exist over this tile or if this tile is empty (erased) before to allow the player creates a sprite there. Any help?

Thanks in advance.

https://www.dropbox.com/s/zvb471nqpoam6 ... .capx?dl=0
B
74
S
14
G
4
Posts: 1,018
Reputation: 8,139

Post » Sun Jan 31, 2016 2:47 pm

Here is a modified .capx that, I hope, does what you expected. The tilemap you're using is just here for coordinates, as the creation of "ressource" object doesn't affect it. "Ressource" object is not a tile and doesn't modify tilemap on creation, so you don't have to test if the tilemap is empty under the pointer, but only if the pointer already overlaps with the object. If not, you can create one at the desired position.

I also modified the coordinates for object creation on the tilemap. The origin of your 32x32 sprite is in the top left corner, so you have to create it at -16/-16 pixels from the position given by the expression TIlemap.SnapX and SnapY.

https://www.dropbox.com/s/vi4gtp4xwc9fnqn/tilemapExample1.capx?dl=0
B
14
S
4
Posts: 112
Reputation: 1,287

Post » Sun Jan 31, 2016 4:34 pm

Great, @Nabu0001

Always learning. Many thanks.

Thanks also for fix the position where the sprite will be created.
B
74
S
14
G
4
Posts: 1,018
Reputation: 8,139


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 27 guests