2012-12-29 57 views
0

我將此代碼添加到我的文件問題將圖像添加到一個Box2D的身體

CCSprite *_ball; 
_ball = [CCSprite spriteWithFile:@"A.jpg" rect:CGRectMake(0, 0, 10, 10)]; 
_ball.position = ccp(20, 20); 
[self addChild:_ball]; 

b2BodyDef ballBodyDef; 
ballBodyDef.type = b2_dynamicBody; 
ballBodyDef.position.Set(20/PTM_RATIO, 20/PTM_RATIO); 
ballBodyDef.userData = _ball; 
_body = world->CreateBody(&ballBodyDef); 

b2CircleShape circle; 
circle.m_radius = 30.0/PTM_RATIO; 

b2FixtureDef ballShapeDef; 
ballShapeDef.shape = &circle; 
ballShapeDef.density = 1.0f; 
ballShapeDef.friction = 0.2f; 
ballShapeDef.restitution = 0.8f; 
_body->CreateFixture(&ballShapeDef 

它運行,但它不顯示圖像A.JPG。爲什麼這個?

回答

0

Box2D與正在顯示或未顯示的精靈無關。你在別的地方有一個bug。也許「自我」沒有被繪製或者_ball是零?