How do I Get Tilemap ID Number on Collision?

0 favourites
  • 4 posts
From the Asset Store
Jump on numbers in the proper order and reach the sun!
  • I have a object that collides with a tile map and then erased tiles maps it collides with. I want to also want to have something happen when certain tiles are erased. for example when tile 0 and tile 1 are erased add 1 to points.

    Here is what my code looks like:

    + leg_Head: On collision with Tilemap_Edible

    ----+ System: For "GroundTileX" from Tilemap_Edible.PositionToTileX(leg_Head.BBoxLeft) to Tilemap_Edible.PositionToTileX(leg_Head.BBoxRight)

    ----+ System: For "GroundTileY" from Tilemap_Edible.PositionToTileY(leg_Head.BBoxTop) to Tilemap_Edible.PositionToTileY(leg_Head.BBoxBottom)

    -----> Tilemap_Edible: Erase tile (LoopIndex("GroundTileX"), LoopIndex("GroundTileY"))

    --------+ Tilemap_Edible: Tile (LoopIndex("GroundTileX"), LoopIndex("GroundTileY")) ≤ 2

    ---------> leg_Head: Shake ScrollTo with magnitude 20 for 0.4 seconds (Reducing magnitude)

    ---------> System: Set MovesLeft to 10

    Thanks in advance for any help :)

  • KSLR I'm not sure if I understood correctly if it's not what you looking for let me know

    https://www.dropbox.com/s/omvg3lelnl5gxxc/TileMap%20Erase%20Zone%20%26%20Add%201%20To%20Points.capx?dl=0

    They are two Tiles = 0

    And Two Tiles = 1

    So The Points Variable it should be equal = 4 by the end of the Loop

    ===================================

    And if for example, you need to check a bunch of numbers that you not able to use the expressions (< OR >) "lower or Less" for example Tiles (0,1,12)

    you can do something like this:

    https://www.dropbox.com/s/0qgfkwv3wphl1rs/TileMap%20Erase%20Zone%20%26%20Add%201%20To%20Points2.capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That solution does work for what I need. It took me a bit to get my head around it but it is successful. Thank you Tarek2

    For some reason using the operator < doesn't work but having a = does. I think that was part of my mistake.

    Thanks again!!

  • No Problem mate, Glad it helped you

    For some reason using the operator < doesn't work but having a = does. I think that was part of my mistake.

    I can't see your events but if you have something similar to the Picture of your Events from your first Post here are a few things to take into consideration:

    -Any Empty Tile will have (ID = -1) so when you comparing using just "<=" Less or equal (2) it will include all the Empty Tiles as they are less than (2)

    you could fix this by a second condition

    (=> 0)

    or

    = -1 <<<<<<<Inverted Negative (Meaning not equal) -1

    ==================================

    -The second thing is the order of the Events it's Very Important as you can see on your Picture you Delete the Tiles before you make the comparison to add the Points and as Result Every single Tile before Rich the Event where you compare the Points will be (ID = -1) so deleting it should happen after you update the Points

    If any of these Two things don't Fixe it I'm not sure what it could be

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