How do I Check If Tile Exists At Position

0 favourites
  • 4 posts
From the Asset Store
Piano tiles
$9.99 USD
Template for a piano tiles game, fully documented in comments and video
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • -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

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)