How do I pick a specific tile ID and modify all tiles with that tile ID?

0 favourites
  • 6 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • I'm currently really confused on how I could select a tile ID from a tile map in order to modify it for all tiles with that specific ID. Lets say when I hover over a spike tile in my tile map it says the tile's ID is 183. For that specific tile, I want an instance variable Boolean (dangerous) to go on. If that Boolean is on for a tile, I want that tile to destroy the player. I only want this Boolean to be on for tiles with the ID from the tile map of 183 (the spikes). How do I do this? Is it even possible to do with a single tile map?

    I haven't found any way to modify all objects according to their tile ID, or even use tile ID from the tile map for conditions in general.


  • It is not possible to add instance variables to individual tiles. There are several other ways you can achieve this.

    1. You can create another tilemap with the same size. In this tilemap define only a few tiles - for example, tile #1 red which will mean dangerous, tile #2 green is walkable, tile #3 blue is water etc. Make this tilemap invisible and place it on top of your main tilemap.

    When player is moving, check tile number under the player on this second tilemap. If tile id is 1, then kill the player.

    2. If you have many dangerous tile types (spikes/lava/swamp), add their IDs into an array "DangerousTilesArray". When player steps on a tile, check if this tile ID is in the array, then kill the player. You can create similar arrays for other types of tiles, for example "TreasureTiles", "SlowdownTiles".

    3. Similar to previous method, but instead of arrays you can use text global variables. Simply create a variable with the list of tiles:

    Variable DangerousTilesList=,5,99,131,183,200,

    Then check if tile ID is in this list using find() expression.

  • Thank you so much for the response! Your second method seems very promising to me. However, I'm still new to construct so ill probably go read up on how to use arrays.

  • I made a little demo for you:

    All mushroom tiles are dangerous. As you step on them, you die.

  • I tried it out and it's great! Although, I'm currently creating a 2D game that's not top down (like Mario). How would I go about doing it for that type of game?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Pretty much the same. But if these dangerous tiles are solid (player walks on top of them), you need to pick the tile which is below the player, so use something like ... PositionToTileY(Player.Y+10)

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