本文整理汇总了C++中CAScale9ImageView::setCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ CAScale9ImageView::setCenter方法的具体用法?C++ CAScale9ImageView::setCenter怎么用?C++ CAScale9ImageView::setCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAScale9ImageView
的用法示例。
在下文中一共展示了CAScale9ImageView::setCenter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setIndicator
void CAIndicator::setIndicator(const DSize& parentSize, const DRect& childrenFrame)
{
CC_RETURN_IF(!this->isVisible());
CC_RETURN_IF(m_bTouch);
CAScale9ImageView* indicator = dynamic_cast<CAScale9ImageView*>(m_pIndicator);
if (m_eType == CAIndicatorTypeHorizontal)
{
float size_scale_x = parentSize.width / childrenFrame.size.width;
size_scale_x = MIN(size_scale_x, 1.0f);
float lenght_scale_x = parentSize.width / 2 - childrenFrame.origin.x;
lenght_scale_x /= childrenFrame.size.width;
DRect rect;
rect.size = m_obContentSize;
rect.size.width *= size_scale_x;
if (lenght_scale_x < size_scale_x / 2)
{
rect.size.width *= lenght_scale_x / (size_scale_x / 2);
}
if (1 - lenght_scale_x < size_scale_x / 2)
{
rect.size.width *= (1 - lenght_scale_x) / (size_scale_x / 2);
}
rect.size.width = MAX(rect.size.height, rect.size.width);
rect.origin = m_obContentSize;
rect.origin.y *= 0.5f;
rect.origin.x *= lenght_scale_x;
rect.origin.x = MAX(rect.origin.x, rect.size.width/2);
rect.origin.x = MIN(rect.origin.x, m_obContentSize.width - rect.size.width/2);
indicator->setCenter(rect);
}
else if (m_eType == CAIndicatorTypeVertical)
{
float size_scale_y = parentSize.height / childrenFrame.size.height;
size_scale_y = MIN(size_scale_y, 1.0f);
float lenght_scale_y = parentSize.height / 2 - childrenFrame.origin.y;
lenght_scale_y /= childrenFrame.size.height;
DRect rect;
rect.size = m_obContentSize;
rect.size.height *= size_scale_y;
if (lenght_scale_y < size_scale_y / 2)
{
rect.size.height *= lenght_scale_y / (size_scale_y / 2);
}
if (1 - lenght_scale_y < size_scale_y / 2)
{
rect.size.height *= (1 - lenght_scale_y) / (size_scale_y / 2);
}
rect.size.height = MAX(rect.size.height, rect.size.width);
rect.origin = m_obContentSize;
rect.origin.x *= 0.5f;
rect.origin.y *= lenght_scale_y;
rect.origin.y = MAX(rect.origin.y, rect.size.height/2);
rect.origin.y = MIN(rect.origin.y, m_obContentSize.height - rect.size.height/2);
indicator->setCenter(rect);
}
}