看到我所有的身体在精灵后面
使用cocos2d和box2d,我正在拍摄一个身体并放置一个跟随他的精灵,现在我不仅想看到精灵,还想看到整个世界的身体形状(盒子和圆圈),以更好地理解我的世界物理。
精灵跟随身体:
world->Step(dt,10,10);
for(b2Body *b=world->GetBodyList(); b; b=b->GetNext()) // b is the list of all bodys in the world and we running on them
{
if(b->GetUserData() !=NULL )
{
CCSprite *sprite=(CCSprite *) b->GetUserData();//every b of the world will be update his position
sprite.position=ccp( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO ) ;
sprite.rotation=-1*CC_RADIANS_TO_DEGREES(b->GetAngle());
}
}
我该怎么做?需要很大的代码吗?
多谢。
using cocos2d and box2d i am taking a body and put a sprite that follow him, now i would like to see not only the sprite but the whole world bodies shapes(boxs,and circles) to understand better my world physics.
the sprite follow a body with :
world->Step(dt,10,10);
for(b2Body *b=world->GetBodyList(); b; b=b->GetNext()) // b is the list of all bodys in the world and we running on them
{
if(b->GetUserData() !=NULL )
{
CCSprite *sprite=(CCSprite *) b->GetUserData();//every b of the world will be update his position
sprite.position=ccp( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO ) ;
sprite.rotation=-1*CC_RADIANS_TO_DEGREES(b->GetAngle());
}
}
how would i do that? is it require a big code ?
thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 b2DebugDraw。下面是代码:
http://www.ccsprite.com/box2d /debugdraw-box2d-cocos2d.html
这将自动绘制你的 b2World。
Use b2DebugDraw. Here is the code how do it:
http://www.ccsprite.com/box2d/debugdraw-box2d-cocos2d.html
That will automatically draw your b2World.