Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am using CCParticleSystemQuad to create particle effects. But I want my sprites to be able to collide with particles. Say your character is a dragon, the dragon breath is a particle effect emitting fire. When the breath hits objects (sprites), I should be able to know it collided with some sprites. How can it be done? Unfortunately google search on this subject doesn't give very good output.

share|improve this question
    
How many particles do you have to deal with at the same time approximately? –  user14170 Mar 12 '12 at 22:14
    
@Byte56 - I thought of that. But when you create fire, you don't have the particles surrounding in exact polygonal shape with NO spaces in between. Can you direct me to an example please? –  DragonBorn Mar 13 '12 at 2:54
    
@user14170 - Maybe 1000 in size to draw fire. –  DragonBorn Mar 13 '12 at 2:54
    
I take it you know Voxatron, yes? lexaloffle.com/voxatron.php –  Lohoris Mar 13 '12 at 11:20

2 Answers 2

up vote 4 down vote accepted

Pixel perfect collision with particles would be very CPU intensive, this would be even worse on a mobile device. You may want to cheat and use a bounding shape to surround the area the particles occupy, and use that bounding shape for collision purposes. This doesn't have to be exact. It's an approximation of the area the particles occupy. I imagine if you actually implemented this and tested it you'd find that it was sufficient for your needs.

share|improve this answer
    
+1. Or use bounding circles for each particle - although that might still be slow on a mobile platform. Spatial hashing could also be fast. –  Jonathan Dickinson Mar 13 '12 at 11:04
    
@Byte56 - That's what I did but it doesn't look real sometimes when the paticles are not appearing in some space of the box but a collision gets still registered. Maybe my logic was not that good. I estimated the size of the particle object and hard coded. –  DragonBorn Mar 13 '12 at 16:38
    
+1'd for the help. What would be your logic in estimating the box surronding the particle object? –  DragonBorn Mar 13 '12 at 16:49
    
That sounds like an excellent new question to ask! Going into things like that in the comments gets messy. –  Byte56 Mar 13 '12 at 20:47
    
Correct answer but not as precise as the one below. –  user14170 Mar 13 '12 at 21:44

The exact answer would be a somewhat Point-In-Polygon algorithm but as mentioned above it will be very (very) time-consuming in real-time and would be more used for simulation purpose.

Most of the time in real-time you can approximate this by using either :

It basically all depends of the average behavior of the shape made by all your particles.

share|improve this answer
    
+1'd for the amazing links. Thank you. –  DragonBorn Mar 13 '12 at 23:08
    
So why not choosing that answer instead? ;) –  user14170 Mar 14 '12 at 10:17
    
Becuase this - "You may want to cheat and use a bounding shape to surround the area the particles occupy, and use that bounding shape for collision purposes." solved my problem without losing several fps. But I appreciate your links as they are quite informative. –  DragonBorn Mar 20 '12 at 17:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.