2014-07-15 1 views
0

나는 chipmunk를 사용하지 않지만 PhysicsEngine, cocos 2d v3 만 사용합니다.CCPhysicsBodyTypeStatic 작동하지 않음

_physicsNode = [CCPhysicsNode node]; 
_physicsNode.collisionDelegate = self; 
_physicsNode.gravity=ccp(0,-165); 
_physicsNode.debugDraw = TRUE; 
[self addChild:_physicsNode]; 

CCNode *handAttachPoint=[CCNode node]; 
handAttachPoint.physicsBody.type=CCPhysicsBodyTypeStatic; 
handAttachPoint.position=ccp(self.contentSize.width/8,self.contentSize.height/2); 
handAttachPoint.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1.0 andCenter:handAttachPoint.anchorPointInPoints]; 
//[email protected][]; 
[_physicsNode addChild:handAttachPoint]; 

나는 handAttachPoint 창에서 정적 노드를 원하는,하지만 여전히 아래로 떨어지고있다 .. :(

어떤 도움에 감사드립니다!

답변

1

당신은 순서가 잘못있어 여기 :.

handAttachPoint.physicsBody.type = CCPhysicsBodyTypeStatic; 

... 

handAttachPoint.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1.0 
           andCenter:handAttachPoint.anchorPointInPoints]; 

physicsBody 아직 할당되지 않은 첫 번째 줄에서, 속성이 nil 일이 아무것도하지 않는 정적 할당, 그것은 무시됩니다. 이후에이 과제를 수행해야만 물리 물리 체를 초기화하고 할당해야합니다.

+0

감사합니다. 작동합니다! :) –