How do I compare a specific tile on a tile map with the tile in the tile image/set?

0 favourites
  • 10 posts
From the Asset Store
Two types of minimap: "full map" and "player is the center" (square map and radial map)
  • Hello!

    Trying to learn all of the capabilities with construct. I found a couple resources but they didn't seem to be working so here I am :)

    I placed specific tiles on a tile map, now when I left click my mouse on a tile, I want it to compare it with a tile that I specified in the tile image/set such as 22, or 3,1 (which ever way it needs to be). I have tried all the positiontotile, tiletoposition, and tileat expressions/conversions but none seem to be passing what I am looking for.

    Thank you for any info!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • TileAt(PositionToTileX(x), PositionToTileY(y))

    where x and y are layout coordinates

  • TileAt(PositionToTileX(x), PositionToTileY(y))

    where x and y are layout coordinates

    Thank you for the response! Hmm,I tried that and get an output of -1.

  • -1 means that the tile is "empty" or "erased"

  • codyto1999

    I tried that and get an output of -1

    that's probably because the x/y coordinates you used were over a tile that is empty/erased

  • I did see that in the documentation. I think I'm just a little confused haha.

    This is what I'm clicking on in the tile map with result in top left:

    gyazo.com/84661a73b6fa509e48305bb3f720cd19

    I thought maybe it was because I have a HUD layer in front of the ground so it was selecting that. I tried moving the tilemap to the front layer and still get -1.

    So is x/y supposed to be the specified coord of the Tile set/image or the coord of the mouse click? I had tried specifying x/y as 2/1 for the tile image as well as tried mouse.x/mouse.y and still got the same result.

    Thank you all for the assistance.

  • Im not sure what could be causing this issue. If you can attach your project or a screenshot of your events that may help figure out what happened.

  • Im not sure what could be causing this issue. If you can attach your project or a screenshot of your events that may help figure out what happened.

    Sure! Here is a the project: dropbox.com/s/pjvdjugdml69wqt/farm.c3p

    Don't mind the mess, haha! Just testing. Under the "Crop Progression" is where I'm trying this. Once I am able to properly get the result I am looking for I would compare it to the specific tile in the tile image and only able to plant the tomato sprite in the dirt if its true.

    Thank you again for the assistance!!

  • I have found the issue :)

    simply change the "tileTopositionX" and "tileTopositionY" to instead:

    "PositionToTileX" and "PositionToTileY"

    The number you get from that can be used to check if a tile is dirt for example. In your case just compare that value and check if it equals 36, as that is the tile index for dirt in your tilemap.

  • I have found the issue :)

    simply change the "tileTopositionX" and "tileTopositionY" to instead:

    "PositionToTileX" and "PositionToTileY"

    The number you get from that can be used to check if a tile is dirt for example. In your case just compare that value and check if it equals 36, as that is the tile index for dirt in your tilemap.

    Perfect! I did have that originally but I don't think I was using the mouse.x and mouse.y. Thank you so much!

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