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

Get help using Construct 2

Post » Fri Nov 14, 2014 10:07 pm

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!
Image
B
7
S
1
Posts: 70
Reputation: 843

Post » Fri Nov 14, 2014 10:24 pm

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

viewtopic.php?f=146&t=118651
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Fri Nov 14, 2014 11:14 pm

Image

might need to right click and open in a new tab to see the whole image
B
87
S
44
G
16
Posts: 1,009
Reputation: 17,946

Post » Fri Nov 14, 2014 11:16 pm

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
B
87
S
44
G
16
Posts: 1,009
Reputation: 17,946

Post » Sat Nov 15, 2014 9:19 pm

Message: saf is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
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):

Code: Select all
Sprite - on collision with - tilemapsolid -> erase tile at - sprite.x, sprite.y


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
Image
B
7
S
1
Posts: 70
Reputation: 843

Post » Sat Nov 15, 2014 9:37 pm

The tilemap.positiontotilex(sprite.x) and tilemap.positiontotiley(sprite.y) will tell you which tile the sprite collided with.
B
87
S
44
G
16
Posts: 1,009
Reputation: 17,946

Post » Sat Nov 15, 2014 9:46 pm

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:

Code: Select all
https: // dl.dropboxusercontent.com / u / 6116050 / tileeraseoncollision. capx


(I can't post links yet)
Image
B
7
S
1
Posts: 70
Reputation: 843

Post » Wed Dec 30, 2015 10:38 pm

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 :)
Image
B
7
S
1
Posts: 70
Reputation: 843


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 57 guests