0
votes

Hi i'm working on cocos2d game some kind of shooter with landscape and targets where you have the targets in front of you as in the real shooting range. for bullet impact i use particle effect that impact at certain point on the screen and when impact on the target it play simple animation and fall on the ground. My game work perfect with rectangular targets but i want to use real body shapes too. So when particle impact the body it fall.And i want to use contour traced sprites so when the particle impact between the legs or between the shoulder an the head shot fails. i use this code to detect when the particle impact the target for normal rectangle targets.

//Sustem is my particle(bullet) CGRect projectileRect = [enemy boundingBox];

if ( CGRectContainsPoint(projectileRect, system.position)) {
    [enemy runAction:_walkAction];}

I tried using vertexHelper physics editor and other tools but no success, i don't want collision detection only to run some action when particle is between some of the traced points

1

1 Answers

1
votes

I feel your pain. There is no simple way to detect non-square collisions. You can use PhysicsEditor and follow Ray's tutorial: how to use box2d for just collision detection. I hated the idea of implementing a physics engine (which, in my opinion, is sloppy) so that I could use non-square sprites. There are other ways around it, such as bezier curves, but in your case (target shooting) I suspect you will need as much accuracy as you can get. PhysicsEditor and box2d/chipmunk will provide that.