문제

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