本文整理汇总了C++中Sprite::GetZoomFactor方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite::GetZoomFactor方法的具体用法?C++ Sprite::GetZoomFactor怎么用?C++ Sprite::GetZoomFactor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite::GetZoomFactor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNearestCharacter
Character* CharacterManager::GetNearestCharacter(Character* c, int angle) {
float angle_rad = angle * 3.1415f / 180.0f;
float x, y, w, h;
c->GetPosition(x, y);
//1 unidade = 32 pixels
//Sprites têm 32 pixels (geralmente) = 1 unidades.
//TODO: Character::Get/SetSize()
w = 32;
h = 32;
Character* destiny = NULL;
for (auto it = _chars.begin();
it != _chars.end();
it++) {
float destx, desty;
(*it)->GetPosition(destx, desty);
Sprite* s;
(*it)->GetSprite(&s);
w = (s->GetFrameWidth() / 32.0f) * s->GetZoomFactor();
h = (s->GetFrameHeight() / 32.0f) * s->GetZoomFactor();
if (destx >= (x - w) && destx <= (x + w)) {
if (desty >= (y - h) && desty <= (y + h)) {
if (c->GetID() != (*it)->GetID()){
/* Otimizado para ângulos retos
TODO: Otimizar de 45 em 45, não é necessário agora*/
bool isOK = false;
switch (angle) {
case 0:
isOK = (destx > x);
break;
case 90:
isOK = (desty > y);
break;
case 180:
isOK = (x > destx);
break;
case 270:
isOK = (y > desty);
break;
case 360:
isOK = true;
}
if (isOK)
destiny = (Character*)(*it);
}
}
}
}
return destiny;
}