本文整理汇总了C++中sf::Sprite::getOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite::getOrigin方法的具体用法?C++ Sprite::getOrigin怎么用?C++ Sprite::getOrigin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Sprite
的用法示例。
在下文中一共展示了Sprite::getOrigin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOBB
Collision::OBB Collision::getOBB(const sf::Sprite& object){
//Gets the oriented bounding box of object, which is the local bounds of the object rotated
sf::FloatRect box(object.getLocalBounds());
maths::Vector2 topleft, botright, topright, botleft;
float rot = object.getRotation();
maths::Vector2 origin = object.getOrigin();
maths::Vector2 position = object.getPosition();
//Get rotated coordinates of vertices
topleft = position + maths::Vector2(box.left, box.top).rotate(rot, origin);
botright = position + maths::Vector2(box.left + box.width, box.top + box.height).rotate(rot, origin);
topright = position + maths::Vector2(box.left + box.width, box.top).rotate(rot, origin);
botleft = position + maths::Vector2(box.left, box.top + box.height).rotate(rot, origin);
return OBB(topleft, botleft, topright, botright);
}
示例2: getOriginalBoundingBox
sf::FloatRect Collision::getOriginalBoundingBox(const sf::Sprite& object){
//Get unrotated bounding box in world coordinates
sf::FloatRect rect = object.getLocalBounds();
maths::Vector2 tl = object.getPosition() - object.getOrigin() + maths::Vector2(rect.left, rect.top);
return sf::FloatRect(tl.x, tl.y, rect.width, rect.height);
}