当前位置: 首页>>代码示例>>C++>>正文


C++ CCClippingNode::ignoreAnchorPointForPosition方法代码示例

本文整理汇总了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);
    }
}
开发者ID:msnvip,项目名称:cocos2dx-better,代码行数:82,代码来源:CCScrollBar.cpp

示例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);
    }
}
开发者ID:msnvip,项目名称:cocos2dx-better,代码行数:95,代码来源:CCScrollBar.cpp


注:本文中的CCClippingNode::ignoreAnchorPointForPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。