本文整理汇总了C++中CEntity::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CEntity::setPosition方法的具体用法?C++ CEntity::setPosition怎么用?C++ CEntity::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEntity
的用法示例。
在下文中一共展示了CEntity::setPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseMoveEvent
//---------------------------------------------------------------------------
void CRenderWidget::mouseMoveEvent(QMouseEvent *event)
{
if (mIsLeftMouseDown && mSelectedItems.size() > 0)
{
// Lookup the entity
CEntity* entity = Globals::getCurrentScene()->getEntityFromGraphicsView(mSelectedItems.first());
if (!entity)
{
QMessageBox::critical(this, "Erreur!", "Impossible de retrouver l'entité attachée au graphique sélectionné!");
return;
}
QPoint delta = event->pos() - mMouseDownPosition;
if (mDoCopySelection)
{
// Hep, stop right there! We want to duplicate the selection, and switch our current pick to the copied
// entity, and move it.
entity = Globals::getCurrentScene()->cloneEntity(entity);
selectEntity(entity->getSceneItem());
mDoCopySelection = false;
}
// Move the entity
QPoint gridDelta = delta;//QPoint(ceil(delta.x() / 16.f) * 16.f, ceil(delta.y() / 16.f) * 16.f);
Vector2D finalPos = mOriginalPosition + Vector2D(gridDelta.x(), gridDelta.y());
entity->setPosition(finalPos);
emit itemChanged();
// Move selection rects
for (QList<QGraphicsItem*>::iterator it = mSelectionRects.begin(); it != mSelectionRects.end(); ++it)
{
QGraphicsItem* rect = (*it);
rect->setPos(gridDelta);
}
}
}
示例2: update
bool CCollisionManager::update()
{
CEntity *entity;
for (entityIter=T_entities.begin(); entityIter!=T_entities.end(); ++entityIter)
{
entity = *entityIter;
/*
Check entities with terrain end make proper response,
all 4 must be checked since we ce be in the corner.
*/
if (entity->isActive())
{
// 1. get logical position
vector2i pos = CConversions::realToLogical(entity->getPosition());
// 2. extract proper planes of nearby block
check(entity,pos+vector2i(0,-1));
check(entity,pos+vector2i(0,1));
check(entity,pos+vector2i(-1,0));
check(entity,pos+vector2i(1,0));
/* ? check(entity,pos+vector2i(1,1));
check(entity,pos+vector2i(1,-1));
check(entity,pos+vector2i(-1,-1));
check(entity,pos+vector2i(-1,1)); ? */
// just clamp entity to the bottom if we are below min level
vector3f ePos = entity->getPosition();
if (ePos[1]<CV_CAMERA_MIN_FPS_Y_POS)
{
ePos[1] = CV_CAMERA_MIN_FPS_Y_POS;
entity->setPosition(ePos);
}
}
}
return true;
}