collision detection
hi guys
i currently have a set of sprites all of a rectangular shape. What i wish to do is implement a color collision on the sprites. So for example the right hand side of some of the sprites might have an invisible color and if that intersects with another card with a different invisible color a collision condition is true. Does anyone know how to achieve this in cocas2d?
i currently have a set of sprites all of a rectangular shape. What i wish to do is implement a color collision on the sprites. So for example the right hand side of some of the sprites might have an invisible color and if that intersects with another card with a different invisible color a collision condition is true. Does anyone know how to achieve this in cocas2d?
Do you really need pixel-level collision detection? Using existing solutions like the polygon collision in Chipmunk would be a lot easier and faster.
Agreeing with Seth on this one-- per-pixel collision is way overkill unless you really, really, REALLY need it.
A trick I used in my first two games was to, instead of considering the rect, consider a bounding circle with diameter equal to the length or width of the rectangle, whichever was smaller. Additionally, I defined a fudge factor that shrunk or expanded that circle. It worked really well and it was easy to boot.
A trick I used in my first two games was to, instead of considering the rect, consider a bounding circle with diameter equal to the length or width of the rectangle, whichever was smaller. Additionally, I defined a fudge factor that shrunk or expanded that circle. It worked really well and it was easy to boot.
Justin Ficarrotta
http://www.justinfic.com
"It is better to be The Man than to work for The Man." - Alexander Seropian
thanks for the response guys,
trouble is i will need different behaviour depending on which side of the rectangle has been touched and no two rectangles have the same rules. So for example for rectangle 1 touching the right side will trigger action A, for rectangle two however that same behaviour can only be triggered if the bottom is touched. Is there a a clean example out there which can put me in the right direction as to the best approach for accomplishing this?
trouble is i will need different behaviour depending on which side of the rectangle has been touched and no two rectangles have the same rules. So for example for rectangle 1 touching the right side will trigger action A, for rectangle two however that same behaviour can only be triggered if the bottom is touched. Is there a a clean example out there which can put me in the right direction as to the best approach for accomplishing this?
That doesn't require pixel-level detection. If your shapes really are just rectangles, then you can figure out which side the collision occurred on. How you do that depends on how you're doing your collision detection (from scratch, using Chipmunk, something else). Determine the necessary collision shapes of your objects, and then add your trigger response onto of that.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Collision detection using the Bullet physics engine | MikeD | 0 | 2,355 |
Aug 30, 2010 11:14 AM Last Post: MikeD |
|
| 2d collision detection trouble | stevemack | 2 | 2,571 |
Jun 23, 2010 11:50 AM Last Post: stevemack |
|

