本文整理汇总了C++中BaseNode::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseNode::setPosition方法的具体用法?C++ BaseNode::setPosition怎么用?C++ BaseNode::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseNode
的用法示例。
在下文中一共展示了BaseNode::setPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: createObject
/*! Slot. This will create a new object at the specified position. The
prototypeID of the new object will have been set by a previous signal
to setNewObjectID. Uses NodeFactory.
*/
void Document::createObject(const QPoint &position) {
assert(indexOfSelectedObject >= -1);
assert(indexOfSelectedObject < static_cast<int>(nodes.size()));
// testing
int objectUnder = getIndexAt(position);
if (objectUnder != -1) {
setSelectedObject(position);
return;
}
// create a new node using the factory
BaseNode* newNode;
newNode = NodeFactory::getInstance()->produce(newObjectID);
newNode->setPosition(position);
// add newnode to a vector of nodes.
addNodeToList(newNode);
// add the node to the ordering
ordering.append(nodes.size()-1);
// reset the selected property of previously selected node
if (indexOfSelectedObject != -1) {
nodes.at(indexOfSelectedObject)->setSelected(false);
}
// set the selected index to be the created object
indexOfSelectedObject = nodes.size()-1;
nodes.at(indexOfSelectedObject)->setSelected(true);
setModified(true);
emit modelChanged();
this->showPropertiesDialog();
setSelectedObject(position);
}