How do I Register "Damage" to Individual Tiles in a Tilemap?

Get help using Construct 2

Post » Sun Dec 07, 2014 8:19 pm

I want to be able to damage tiles when they are hit but I want some tiles to be more durable than others. I know that tilemaps can have instance variables but they seem to apply to the whole tilemap and not just the tile being affected. I want the individual tile to remember that it is damaged. The only solution I can see is to create multiple tilemaps with different variables of "durability" and when it gets damaged I replace it with one of a lower durability. Is there some other solution possible or is having many different versions of a tilemap the only way of doing it? Thank you in advance for your response!
B
3
Posts: 8
Reputation: 191

Post » Sun Dec 07, 2014 9:52 pm

You can use an array to store each tile's state in, indexed by the tile indices.
ImageImageImage
B
71
S
22
G
248
Posts: 3,760
Reputation: 138,071

Post » Sun Dec 07, 2014 11:24 pm

Thank you. My question feels dumb now. Still wrapping my head around how to properly integrate arrays into what I want to do. I just tried storing the tile state in an array and subtracting its "health" when a bullet collides with it, however it only subtracts it once. So with a default value of 3, it subtracts to 2, but won't subtract further upon further bullet collisions. I don't know if I need some kinda for loop or something but I have included a snapshot.
You do not have the required permissions to view the files attached to this post.
Last edited by SarcasticNash on Mon Dec 08, 2014 9:41 am, edited 1 time in total.
B
3
Posts: 8
Reputation: 191

Post » Sun Dec 07, 2014 11:49 pm

You can't use CurValue, you need to index it explicitly: Array.At(...,...)
ImageImageImage
B
71
S
22
G
248
Posts: 3,760
Reputation: 138,071

Post » Mon Dec 08, 2014 9:37 am

Thank you for your help! I have it working now with this. :-)
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 8
Reputation: 191


Return to How do I....?

Who is online

Users browsing this forum: jezjones24, Lancifer, newt, R0J0hound and 22 guests