本文整理汇总了C++中CCClippingNode::ignoreAnchorPointForPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CCClippingNode::ignoreAnchorPointForPosition方法的具体用法?C++ CCClippingNode::ignoreAnchorPointForPosition怎么用?C++ CCClippingNode::ignoreAnchorPointForPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCClippingNode
的用法示例。
在下文中一共展示了CCClippingNode::ignoreAnchorPointForPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attachToUIScrollView
void CCScrollBar::attachToUIScrollView(ScrollView* scrollView, ccInsets insets, bool horizontal) {
// save flag
m_horizontal = horizontal;
// add to scroll view
float thumbLength = 0;
Widget* svParent = dynamic_cast<Widget*>(scrollView->getParent());
CCSize svSize = scrollView->getSize();
CCPoint svOrigin = CCUtils::getOrigin(scrollView);
CCSize innerSize = scrollView->getInnerContainerSize();
CCSize sbSize;
if(horizontal) {
sbSize = CCSizeMake(m_track->getContentSize().width,
svSize.width - insets.left - insets.right);
setContentSize(sbSize);
setAnchorPoint(ccp(0, 0.5f));
setPosition(ccp(svOrigin.x + svSize.width / 2,
svOrigin.y + insets.bottom));
setRotation(-90);
svParent->addNode(this, MAX_INT);
// thumb length
if(m_fixedThumb)
thumbLength = m_fixedThumb->getContentSize().height;
else
thumbLength = MIN(1, svSize.width / innerSize.width) * sbSize.height;
} else {
sbSize = CCSizeMake(m_track->getContentSize().width,
svSize.height - insets.top - insets.bottom);
setContentSize(sbSize);
setAnchorPoint(ccp(1, 0.5f));
setPosition(ccp(svOrigin.x + svSize.width - insets.right,
svOrigin.y + svSize.height / 2));
svParent->addNode(this, MAX_INT);
// thumb length
if(m_fixedThumb)
thumbLength = m_fixedThumb->getContentSize().height;
else
thumbLength = MIN(1, svSize.height / innerSize.height) * sbSize.height;
}
// add track
m_track->setPreferredSize(sbSize);
m_track->setPosition(CCUtils::getLocalCenter(this));
addChild(m_track);
// clipping node to hold thumb
CCClippingNode* thumbClipping = CCClippingNode::create(m_track);
thumbClipping->ignoreAnchorPointForPosition(false);
thumbClipping->setAnchorPoint(ccp(0.5f, 0.5f));
thumbClipping->setContentSize(sbSize);
thumbClipping->setPosition(CCUtils::getLocalCenter(this));
thumbClipping->setAlphaThreshold(0.5f);
thumbClipping->setScaleX((sbSize.width - 4) / sbSize.width);
thumbClipping->setScaleY((sbSize.height - 4) / sbSize.height);
addChild(thumbClipping);
// thumb or fixed thumb
if(m_thumb) {
m_thumb->setPreferredSize(CCSizeMake(sbSize.width, thumbLength));
m_thumb->setPosition(ccp(sbSize.width / 2,
sbSize.height - thumbLength / 2));
thumbClipping->addChild(m_thumb);
} else {
m_fixedThumb->setPosition(ccp(sbSize.width / 2,
sbSize.height - thumbLength / 2));
thumbClipping->addChild(m_fixedThumb);
}
// sync thumb position
syncThumbPositionForUIScrollView(scrollView);
// listen to scrollview scrolling event
scrollView->addEventListenerScrollView(this, scrollvieweventselector(CCScrollBar::onUIScrollViewEvent));
// init fade out
if(m_initFadeOut) {
m_fadingOut = true;
CCUtils::setOpacityRecursively(this, 0);
}
}
示例2: attachToCCScrollView
void CCScrollBar::attachToCCScrollView(CCScrollView* scrollView, ccInsets insets, bool horizontal) {
// it must have parent node
CCNode* svParent = scrollView->getParent();
if(!svParent) {
CCLOGWARN("CCScrollView must be added to one node before calling attachToCCScrollView");
return;
}
// save flag
m_horizontal = horizontal;
// add to scroll view
float thumbLength = 0;
CCPoint svOrigin = CCUtils::getOrigin(scrollView);
CCSize svSize = scrollView->getViewSize();
CCSize innerSize = scrollView->getContainer()->getContentSize();
CCSize sbSize;
if(horizontal) {
sbSize = CCSizeMake(m_track->getContentSize().width,
svSize.width - insets.left - insets.right);
setContentSize(sbSize);
setAnchorPoint(ccp(0, 0.5f));
setPosition(ccp(svOrigin.x + svSize.width / 2, svOrigin.y + insets.bottom));
setRotation(-90);
UIWidget* svpWidght = dynamic_cast<UIWidget*>(svParent);
if(svpWidght)
svpWidght->addNode(this, MAX_INT);
else
svParent->addChild(this, MAX_INT);
// thumb length
if(m_fixedThumb)
thumbLength = m_fixedThumb->getContentSize().height;
else
thumbLength = MIN(1, svSize.width / innerSize.width) * sbSize.height;
} else {
sbSize = CCSizeMake(m_track->getContentSize().width,
svSize.height - insets.top - insets.bottom);
setContentSize(sbSize);
setAnchorPoint(ccp(1, 0.5f));
setPosition(ccp(svOrigin.x + svSize.width - insets.right, svOrigin.y + svSize.height / 2));
UIWidget* svpWidght = dynamic_cast<UIWidget*>(svParent);
if(svpWidght)
svpWidght->addNode(this, MAX_INT);
else
svParent->addChild(this, MAX_INT);
// thumb length
if(m_fixedThumb)
thumbLength = m_fixedThumb->getContentSize().height;
else
thumbLength = MIN(1, svSize.height / innerSize.height) * sbSize.height;
}
// add track
m_track->setPreferredSize(sbSize);
m_track->setPosition(CCUtils::getLocalCenter(this));
addChild(m_track);
// clipping node to hold thumb
CCClippingNode* thumbClipping = CCClippingNode::create(m_track);
thumbClipping->ignoreAnchorPointForPosition(false);
thumbClipping->setAnchorPoint(ccp(0.5f, 0.5f));
thumbClipping->setContentSize(sbSize);
thumbClipping->setPosition(CCUtils::getLocalCenter(this));
thumbClipping->setAlphaThreshold(0.5f);
thumbClipping->setScaleX((sbSize.width - 4) / sbSize.width);
thumbClipping->setScaleY((sbSize.height - 4) / sbSize.height);
addChild(thumbClipping);
// thumb or fixed thumb
if(m_thumb) {
m_thumb->setPreferredSize(CCSizeMake(sbSize.width, thumbLength));
m_thumb->setPosition(ccp(sbSize.width / 2,
sbSize.height - thumbLength / 2));
thumbClipping->addChild(m_thumb);
} else {
m_fixedThumb->setPosition(ccp(sbSize.width / 2,
sbSize.height - thumbLength / 2));
thumbClipping->addChild(m_fixedThumb);
}
// sync thumb position
syncThumbPositionForCCScrollView(scrollView);
// delegate
m_oldCCDelegate = scrollView->getDelegate();
scrollView->setDelegate(this);
// init fade out
if(m_initFadeOut) {
m_fadingOut = true;
CCUtils::setOpacityRecursively(this, 0);
}
}