How do I change tilemap tile, based on collision

Just started using Construct 2? Post your questions here

Post » Fri Feb 12, 2016 1:03 pm

I've never worked with tilemaps before (shame on me) and I have a collisionbox (an object) that moves over the screen. I want it to change the tile from 0 to 1 when it has collision, but all I can find is "compare tile at". within the tilemap. Any suggestions?
B
3
Posts: 9
Reputation: 193

Post » Sun Feb 14, 2016 1:14 pm

Anyone?
B
3
Posts: 9
Reputation: 193

Post » Sun Feb 14, 2016 1:35 pm

Try:

Sprite| Is overlapping Tilemap -> Tilemap|Set tile (Tilemap.PositionToTileX(Sprite.X),Tilemap.PositionToTileY(Sprite.Y) to tile 1

sprite is your collisionbox, tile 1 is the number of the tile you want in exchange.
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Mon Feb 15, 2016 8:53 am

Asmodean, this sort-of works, except that it only changes the tile that's in collision with the image point and not the object. Other than that it works good.
B
3
Posts: 9
Reputation: 193

Post » Mon Feb 15, 2016 10:48 am

You could try with setting a range of tiles. If you pick the upper left corner of your object with x=Sprite.X-Sprite.Width/2, y= Sprite.Y-Sprite.Height/2 (Origin had to be set in the middle of the sprite) and the multiple of the tiles to the sprite: width = sprite.width/tileWidth height = sprite.height/tileHight:

Sprite| Is overlapping Tilemap -> Tilemap|Set tiles at (Tilemap.PositionToTileX(Sprite.X-Sprite.Width/2)),Tilemap.PositionToTileY(Sprite.Y-Sprite.Height/2)) with area ceil (Sprite.width/32) x ceil(Sprite.Height/32) to tile 1

The tile width and height is in this example 32.
B
24
S
3
G
1
Posts: 451
Reputation: 2,165


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest