本文整理汇总了C++中MapObject::getPositionX方法的典型用法代码示例。如果您正苦于以下问题:C++ MapObject::getPositionX方法的具体用法?C++ MapObject::getPositionX怎么用?C++ MapObject::getPositionX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapObject
的用法示例。
在下文中一共展示了MapObject::getPositionX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Distance
MapObject* CMapObjectManager::getObjectNearBy(int cx,int cy,MapObjectType type)
{
Rect rect;
m_pMap->getViewRect(rect);
float x = 0;
float y = 0;
MapObject* pRet = NULL;
const int minD = 3; //最小格子距离
for ( MapObjectList::iterator itr = m_Objects.begin();itr != m_Objects.end();++itr)
{
MapObject* pObject = *itr;
if ( pObject && !pObject->GetDeleted() )
{
x = pObject->getPositionX();
y = pObject->getPositionY();
int distance = Distance(cx,cy,pObject->GetCellX(),pObject->GetCellY());
if ( rect.containsPoint(Point(x,y)) && pObject->GetType() == type && distance < minD )
{
pRet = pObject;
//minD = distance;
}
}
}
return pRet;
}
示例2:
int CMapObjectManager::getObjectsInView(MapObjectType type,MapObjectList& objects)
{
Rect rect;
m_pMap->getViewRect(rect);
float x = 0;
float y = 0;
for ( MapObjectList::iterator itr = m_Objects.begin();itr != m_Objects.end();++itr)
{
MapObject* pObject = *itr;
if ( pObject && !pObject->GetDeleted() )
{
x = pObject->getPositionX();
y = pObject->getPositionY();
if ( rect.containsPoint(Point(x,y)) && pObject->GetType() == type )
{
objects.push_back(pObject);
}
}
}
return (int)objects.size();
}