本文整理汇总了C++中BaseNode::SetBody方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseNode::SetBody方法的具体用法?C++ BaseNode::SetBody怎么用?C++ BaseNode::SetBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseNode
的用法示例。
在下文中一共展示了BaseNode::SetBody方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SpawnAsteroid
Asteroid* Game::SpawnAsteroid(const Vector2& position, const GameSide& side)
{
// Main
ObjectId objId = this->SpawnEntity();
Asteroid* unit = new Asteroid(this, -1);
this->addComponent(objId, unit);
// Render Component
BaseNode* graphic = new BaseNode(kSpriteAsteroid);
graphic->setPosition(position.x, position.y);
graphic->setScale(0.5f);
GFGame::Components::RenderComponent* node = new GFGame::Components::RenderComponent(graphic);
this->addComponent(objId, node);
// Physics Component
GFGame::Components::PhysicsComponent* physics = new GFGame::Components::PhysicsComponent();
b2Body* body = GFort::Core::Physics::PhysicsHelper::CreateCircle(
phys_controller_.World(),
b2_dynamicBody,
position,
min(graphic->getContentSize().width, graphic->getContentSize().height) * 0.5 * graphic->getScale());
body->SetFixedRotation(false);
body->SetAngularDamping(0);
body->SetAngularVelocity(10);
// Set the dynamic body fixture.
b2Fixture* fixture = body->GetFixtureList();
b2Filter filter = fixture[0].GetFilterData();
filter.categoryBits = kCategoryBitsObstacle;
filter.maskBits = kMaskBitsObstacle;
fixture[0].SetFilterData(filter);
physics->AddBody("root", body);
graphic->SetBody(body);
this->addComponent(objId, physics);
unit->physics_component_ = physics;
return unit;
//return objId;
}