How do I Check If Tile Exists At Position

Get help using Construct 2

Post » Sun Aug 30, 2015 8:45 am

Working on a simple procedural generation system for a mobile digging game for the Underground Jam, but I can't seem to find an option for checking whether a tile exists at a specified position.

I need this to create the water tiles at the right positions. :P
ImageImage
B
49
S
15
G
2
Posts: 270
Reputation: 6,649

Post » Sun Aug 30, 2015 4:47 pm

make a system condition that compares two values, and then put
tilemap.TileAt(tilex,tiley)

To get the x and y tile position, there are also expressions where you provide a layout x,y coordinate to get the x,y tile position.

I think it is something like tilemap.PositionToTile(x)

so it would be something like
tilemap.TileAt(tilemap.PositionToTileX(x),tilemap.PositionToTileY(x))
Then in the second value use a value of the tile you want to check. I can't remember is the tile numbers start at 0 or 1, but they begin in the top left of the tilemap image.
You can check if it is -1 to see if no tile exists at that location.
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Post » Sun Aug 30, 2015 11:41 pm

-1 would mean there is no tile at that position? That seems to be my only issue, because although that's what I'm checking, it's not giving me the correct results. I'm fine in every other regard, but certain blank spaces don't seem to return -1. I might be having an issue elsewhere that Im not seeing.

Thank you! You've cleared it up a little for me, maybe I can find out what's going on :)
ImageImage
B
49
S
15
G
2
Posts: 270
Reputation: 6,649

Post » Sun Aug 30, 2015 11:50 pm

If you have any tiles in your image that are completely transparent, it might be that those are being used somewhere in the tilemap, which would return something other than -1.
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395


Return to How do I....?

Who is online

Users browsing this forum: Phacanu and 10 guests