cocos2dx box2d 炮弹不打自己人怎么做

 我来答
匿名用户
推荐于2016-05-30
展开全部
b2BodyDef groundBodyDef;
groundBodyDef.type = b2_staticBody;
groundBodyDef.position.Set(0, 0);//相当于cocos2d的锚点
b2Body* groundBody = _world->CreateBody(&groundBodyDef);

//b2FixtureDef--->b2Fixture
b2EdgeShape groundShape;
b2FixtureDef groundFixDef;
groundFixDef.shape = &groundShape;
groundShape.Set(b2Vec2(0, 0), b2Vec2(screenSize.width / PTM_RATIO, 0)); //屏幕的底部墙
groundBody->CreateFixture(&groundFixDef);
groundShape.Set(b2Vec2(0, 0), b2Vec2(0, screenSize.height / PTM_RATIO)); //屏幕的左边墙
groundBody->CreateFixture(&groundFixDef);
groundShape.Set(b2Vec2(0, screenSize.height / PTM_RATIO),
b2Vec2(screenSize.width / PTM_RATIO, screenSize.height / PTM_RATIO)); //屏幕的上部墙
groundBody->CreateFixture(&groundFixDef);
groundShape.Set(b2Vec2(screenSize.width / PTM_RATIO, 0),
b2Vec2(screenSize.width / PTM_RATIO, screenSize.height / PTM_RATIO)); //屏幕的右边墙
groundBody->CreateFixture(&groundFixDef);
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式