How do I replace a tile in a tilemap on collision?

From the Asset Store
slide the tiles to fill the board.60 awesome levels.
  • I'm struggling with tilemap and collisions in a platformer. I have two tilemaps, one is "black" squares and they are solid, and the other is "white" squares and they are jumptrough. I'd like to achieve that when a bullet sprite collides with a black square it gets replaced with a white square... So that only the black square that was hit by a sprite gets replaced with white square... Any advice is appreciated!

  • This has been discussed before...there are probably better answers, but here is an example of mine where this is happening (tile type filtered cols):

  • might need to right click and open in a new tab to see the whole image

  • So basically upon each time the bullet collides with a tile thats in a state you want to do something with eg: your black squares (tile number 15 or whatever).

    you change the tile at that location to a different tile.

    Or if you have the two tilemaps overtop of each other, put the white one on the bottom, and the back one on the top. then simply destroy or hide the top back tile, revealing the white one below

  • Thank you for your replies, however, I'm still strugglin' with matching the sprites coordinates with the tile coordinates.

    I thought that something like this would work (over simplified):

    Sprite - on collision with - tilemapsolid -> erase tile at - sprite.x, sprite.y[/code:330yccn9]
    
    It doesn't...
    
    I've created very simple setup (only the sprite isn't a bullet, but rather a platformer, so if anyone has a min or two to take a look...Thanx
  • The tilemap.positiontotilex(sprite.x) and tilemap.positiontotiley(sprite.y) will tell you which tile the sprite collided with.

  • Yes, I've tired that (that's what I used, in the post above I simplified the code a bit, principle is the same), if you take a look here:

    https: // dl.dropboxusercontent.com / u / 6116050 / tileeraseoncollision. capx[/code:20zwv9em]
    
    (I can't post links yet)
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • back on this issue, still haven't found a satisfying solution for this problem, so once again, I come here for help. So I prepared a simple setup:

    https://www.dropbox.com/s/nu1i6c08gfzgm ... .capx?dl=0

    Two tilemaps one red tiles, one blue tiles and "Bullet" sprite. What I'd like to achieve is the following:

    1. When sprite colides with blue tile, the tile flashes for 1 sec and than gets replaced with red tile.

    2. When sprite colides with red tile, the tile flashes for 1 sec and then gets erased

    Any help is appritiated <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

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