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

0 favourites
  • 6 posts
From the Asset Store
Each tile 64 by 64 pixels - Ultimate Tile Set for your awesome games
  • 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.

    Tagged:

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

    dropbox.com/s/5jd5tsswomp8d1h/TilemapDangerousTiles.c3p

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

  • Try Construct 3

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

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

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