本文整理汇总了C++中Sprite::GetTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite::GetTransform方法的具体用法?C++ Sprite::GetTransform怎么用?C++ Sprite::GetTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite::GetTransform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hotspotAdjust
const Matrix3x4& Sprite::GetTransform() const
{
if (positionDirty_)
{
Vector2 pos = floatPosition_;
Matrix3x4 parentTransform;
if (parent_)
{
Sprite* parentSprite = dynamic_cast<Sprite*>(parent_);
if (parentSprite)
parentTransform = parentSprite->GetTransform();
else
{
const IntVector2& parentScreenPos = parent_->GetScreenPosition() + parent_->GetChildOffset();
parentTransform = Matrix3x4::IDENTITY;
parentTransform.SetTranslation(Vector3((float)parentScreenPos.x_, (float)parentScreenPos.y_, 0.0f));
}
switch (GetHorizontalAlignment())
{
case HA_LEFT:
break;
case HA_CENTER:
pos.x_ += (float)(parent_->GetSize().x_ / 2);
break;
case HA_RIGHT:
pos.x_ += (float)parent_->GetSize().x_;
break;
}
switch (GetVerticalAlignment())
{
case VA_TOP:
break;
case VA_CENTER:
pos.y_ += (float)(parent_->GetSize().y_ / 2);
break;
case VA_BOTTOM:
pos.y_ += (float)(parent_->GetSize().y_);
break;
}
}
else
parentTransform = Matrix3x4::IDENTITY;
Matrix3x4 hotspotAdjust(Matrix3x4::IDENTITY);
hotspotAdjust.SetTranslation(Vector3((float)-hotSpot_.x_, (float)-hotSpot_.y_, 0.0f));
Matrix3x4 mainTransform(Vector3(pos, 0.0f), Quaternion(rotation_, Vector3::FORWARD), Vector3(scale_, 1.0f));
transform_ = parentTransform * mainTransform * hotspotAdjust;
positionDirty_ = false;
// Calculate an approximate screen position for GetElementAt(), or pixel-perfect child elements
Vector3 topLeftCorner = transform_ * Vector3::ZERO;
screenPosition_ = IntVector2((int)topLeftCorner.x_, (int)topLeftCorner.y_);
}
return transform_;
}