cocos2d v3 collision detection

前端 未结 1 933
死守一世寂寞
死守一世寂寞 2021-01-23 09:44

I\'m trying to inspect collision collision of two bodies, but collision detection callbacks are not being fired. Here is my code:

1) My CCScene implements CCPhysicsColli

相关标签:
1条回答
  • 2021-01-23 10:04

    In cocos2d v3 physics, collisionType eliminates the need to set integer bit masks to define the type of collision. The parameter name CCPhysicsCollisionDelegate methods must be the collisionTypes that you want to deal with yourself. So in your case , the collision callback method should be

    - (BOOL)ccPhysicsCollisionBegin:(CCPhysicsCollisionPair *)pair body1:(CCNode *)nodeA     body2:(CCNode *)nodeB
    {
        NSLog(@"HELLO");
        return YES;
    }
    

    By default everything collides in cocos2d, but if you set the collisionGroup of two bodies to be the same then they wouldn't collide.

    0 讨论(0)
提交回复
热议问题