"Connected" sprites

Get help using Construct 2

Post » Mon Oct 22, 2012 3:28 pm

Hello,

I've faced another problem. I have a playing field inside my game which is based on tiles (I've used the "Jump&Run" Tutorial as a base for it). On this field there are some bombs which can detonate if the player fire them. If there are bombs on the neighbor field they should also explode. There are different kind of bombs with a different "explosion" radius in that other bombs should also explode...

Any idea how I can implement this feature? I've tried to check if another bomb is inside the explosion radius but it didn't work. I've also tried to give all bombs an instance variable (x,y) and check if another bomb is on a neighbor field, but this looks to be "not right"... :-(

Best,

Benny
B
6
S
1
Posts: 19
Reputation: 888

Post » Mon Oct 22, 2012 3:35 pm

I've found something using the "distance" expression:

http://www.scirra.com/forum/how-do-i-get-all-objects-in-a-radius_topic48595_post305201.html#305201

My current object is called "bomb" and I want all "bombs" in a specific radius to also explode... how can I do it with the engine?

"for each objectThatyouwantTopick
>-distance(pointofexplosion.x,pointofexplosion.y, objectThatyouwantTopick.x, objectThatyouwantTopick.y) < radius, do stuff"

Means:

for each bomb
>-distance(bomb.x,bomb.y,bomb[from foreach].x, bomb[from foreach].y) < radius

How can I seperate between the items of the foreach and the bomb item that has exploded?

Best,

Benny
B
6
S
1
Posts: 19
Reputation: 888

Post » Mon Oct 22, 2012 3:37 pm

A different solution might be to create an invisible circle sprite when a bomb explodes, and then check which other bombs are overlapping it. You could change the scale of the radius for lots of different occasions based on your gameplay.
B
50
S
21
G
8
Posts: 844
Reputation: 10,299


Return to How do I....?

Who is online

Users browsing this forum: CavalierBubble, Evanetot and 24 guests