Just as the title suggests. The selector ccPhysicsCollisionBegin is being called with the right node type names but the passed nodes in the parameters are both nil. Any reason for this?

Thank You

有帮助吗?

解决方案

Thanks! I found out what the problem was. If a node inherits from CCNode and tries to define a physics body without using the property but directly through the ivar _physicsBody, it would result in _physicsBody.node not being set. When the ccPhysicsCollisionBegin is called, the parameters are nil even though the Chipmunk bodies are there.

To avoid this, one must assign a physics body through the property instead of the ivar (which should be private).

You can check out the original thread from the Cocos2d-iphone forum here: http://forum.cocos2d-iphone.org/t/cocos2d-3-0-physics-collision-begin-selector-called-with-nil-parameters/13316

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top