Cocos2d iphone CCPhysisByTypeStatic不工作

Cocos2d iphone CCPhysisByTypeStatic不工作,cocos2d-iphone,physics-engine,Cocos2d Iphone,Physics Engine,我没有使用花栗鼠,但只有PhysicsEngine,Cocos2dv3 _physicsNode = [CCPhysicsNode node]; _physicsNode.collisionDelegate = self; _physicsNode.gravity=ccp(0,-165); _physicsNode.debugDraw = TRUE; [self addChild:_physicsNode]; CCNode *handAttachPoint=[CCNode node]; han

我没有使用花栗鼠,但只有PhysicsEngine,Cocos2dv3

_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];
//handAttachPoint.physicsBody.collisionMask=@[];
[_physicsNode addChild:handAttachPoint];
我希望节点handAttachPoint在窗口中是静态的,但它仍在下降..:(


感谢您的帮助!!

您在这里的订单错了:

handAttachPoint.physicsBody.type = CCPhysicsBodyTypeStatic;

...

handAttachPoint.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1.0
                               andCenter:handAttachPoint.anchorPointInPoints];
在第一行中,尚未分配physicsBody,属性为nil。分配static在那里不起任何作用,它将被忽略。在初始化和分配physics body后,必须执行此分配