How do I check if an object is overlapping a tile?

0 favourites
  • 2 posts
From the Asset Store
Each tile 64 by 64 pixels - Ultimate Tile Set for your awesome games
  • I have a tilemap that has four tiles, and i need to write every tile's state (tile position and it's id) into an array.

    But i need to check also if there is an object overlapping a tile, and set another value (boolean) to array based on object overlapping.

    So, after the loop, array should look like this:

    Index TileX TileY TileId Overlaps
    0 0 0 0 0
    0 0 1 1 1
    0 1 0 2 0
    0 1 1 3 1

    0: 0, 0, 0, 0 --> last value means that this tile does not overlap with an object

    1: 0, 1, 1, 1 --> this tile overlaps with an object

    2: 1, 0, 2, 0 --> same with this one

    2: 1, 1, 3, 1 --> same with this one

    Main idea with this functionality is that after loading tilemap from JSON (on every start of the layout) i need to check tile id and it's overlapping value. If overlapping value has 1, then i change tile's id to a specific value. If overlapping value is 0, then i set tile's id to it's current id-1.

    At the moment i'm stuck with an overlapping part. I'm a beginner with with an arrays, and manipulating tilemaps, so i would be very thankful if someone could help me.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You probably need to loop through all tiles and use System Pick Overlapping Point condition.

    + System: For "x" from 0 to Tilemap.MapDisplayWidth
    + System: For "y" from 0 to Tilemap.MapDisplayHeight
    
    ------+ System: Pick Sprite overlapping (Tilemap.TileToPositionX(LoopIndex("x")), Tilemap.TileToPositionY(LoopIndex("y")))
    
    ---------> Array Set At (LoopIndex("x"), LoopIndex("y")) ..........
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)