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


C++ convertToNodeSpace函数代码示例

本文整理汇总了C++中convertToNodeSpace函数的典型用法代码示例。如果您正苦于以下问题:C++ convertToNodeSpace函数的具体用法?C++ convertToNodeSpace怎么用?C++ convertToNodeSpace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了convertToNodeSpace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: convertToNodeSpace

bool UIBuyBuildingLayer::isTouchEdge(Touch* touch)
{
	Point local = convertToNodeSpace(touch->getLocation());
	auto rect = Rect(0,317 + 100,Director::getInstance()->getWinSize().width,Director::getInstance()->getWinSize().height - 417);
	if (rect.containsPoint(local))
	{   
		return true;
	}
	return false;
}
开发者ID:joyfish,项目名称:MyCocos2dx,代码行数:10,代码来源:UIBuyBuildingLayer.cpp

示例2: ccp

 void CCLayerPanZoom::setScaleY(float fScaleY)
 {
     fScaleY = (MIN(MAX(fScaleY, _minScale), _maxScale));
     
     CCPoint winOrigin = CCDirector::sharedDirector()->getVisibleOrigin();
     CCSize winSize = CCDirector::sharedDirector()->getVisibleSize();
     CCPoint screenCenter = ccp(winOrigin.x + winSize.width * 0.5f, winOrigin.y + winSize.height * 0.5f);
     
     CCPoint centerBefore = convertToNodeSpace(screenCenter);
     
     CCNode::setScaleY(fScaleY);
     
     CCPoint centerAfter = convertToNodeSpace(screenCenter);
     
     CCPoint centerPointDelta  = ccpSub(centerAfter,centerBefore);
     centerPointDelta = ccpMult(centerPointDelta, fScaleY);
     
     move(centerPointDelta);
 }
开发者ID:NStockwell,项目名称:SocialPoint,代码行数:19,代码来源:CCLayerPanZoom.cpp

示例3: convertToNodeSpace

CWidgetTouchModel CSlider::onTouchBegan(CCTouch *pTouch)
{
	if (!m_bDragable)
	{
		return eWidgetTouchNone;
	}

	m_bDrag = m_pSlider->boundingBox().containsPoint(
		convertToNodeSpace(pTouch->getLocation())
	);

	if( m_bDrag )
	{
		changeValueAndExecuteEvent(valueFromPoint(convertToNodeSpace(pTouch->getLocation())), true);
		return eWidgetTouchSustained;
	}

	return eWidgetTouchNone;
}
开发者ID:54993306,项目名称:Classes,代码行数:19,代码来源:Slider.cpp

示例4: convertToNodeSpace

bool Layout::hitTest(const CCPoint &pt)
{
    CCPoint nsp = convertToNodeSpace(pt);
    CCRect bb = CCRect(0.0f, 0.0f, _size.width, _size.height);
    if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height)
    {
        return true;
    }
    return false;
}
开发者ID:fordream,项目名称:quick,代码行数:10,代码来源:UILayout.cpp

示例5: convertToNodeSpace

bool Widget::hitTest(const Point &pt)
{
    Point nsp = convertToNodeSpace(pt);
    Rect bb = Rect(-_size.width * _anchorPoint.x, -_size.height * _anchorPoint.y, _size.width, _size.height);
    if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height)
    {
        return true;
    }
    return false;
}
开发者ID:12white,项目名称:CocoStudioSamples,代码行数:10,代码来源:UIWidget.cpp

示例6: convertToNodeSpace

/////////////////////////////////////////////////////////
// Touch on left side of screen moves player left
// Touch on right side of screen moves player right
void GameScene::ccTouchEnded(CCTouch* touch, CCEvent* event)
{
	CCPoint touchLocation = touch->getLocationInView(  );	
	touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);
	touchLocation =  convertToNodeSpace(touchLocation);

	float touchCenter =  CCDirector::sharedDirector()->getWinSize().width/2 - touchLocation.x;
	float accel_filter = 0.1f;
	bird_vel.x = bird_vel.x * accel_filter - touchCenter;  
}
开发者ID:Sarahmarieeaton,项目名称:tweejump-cocos2dx,代码行数:13,代码来源:GameScene.cpp

示例7: convertToNodeSpace

bool Box2DView::ccTouchBegan(CCTouch* touch, CCEvent* event)
{
	CCPoint touchLocation = touch->locationInView( touch->view() );	
	touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );

	CCPoint nodePosition = convertToNodeSpace( touchLocation );
//	NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y);

	return m_test->MouseDown(b2Vec2(nodePosition.x,nodePosition.y));	
}
开发者ID:YarinYang,项目名称:cocos2dx-win8,代码行数:10,代码来源:Box2dView.cpp

示例8: convertToNodeSpace

bool GameSprite_Gold::isTouchInside( CCTouch* touch )
{
    CCPoint touchLocation = touch->getLocation(); // Return to GL coordinates
    CCPoint localPos = convertToNodeSpace(touchLocation);
    CCRect rc = rect();
    rc.origin = CCPointZero;
    bool isTouched = rc.containsPoint(localPos);
    
    return isTouched;
}
开发者ID:anzhongliu,项目名称:SmallGame_Cocos2dx,代码行数:10,代码来源:GameSprite_Gold.cpp

示例9: convertToNodeSpace

bool CCSpriteEx::isTouchInside( CCTouch* touch )
{
    CCPoint touchLocation = touch->getLocation(); // 返回GL坐标

    CCPoint localPos = convertToNodeSpace(touchLocation);
    CCRect rc = rect();
    rc.origin = CCPointZero;
    bool isTouched = rc.containsPoint(localPos);
    return isTouched;
}
开发者ID:edudemy,项目名称:customized--portraits,代码行数:10,代码来源:CCSpriteEx.cpp

示例10: convertToNodeSpace

void CCutScene::checkFoodSliced()
{
    if (m_nSliceCount >= 8)
    {
        //todo:暂时不能切,播放庆祝特效
        
        m_nSliceCount = 0;
        CFoodCut* pFood = NULL;
        int nIndex = -1;
        int nCount = m_vCutFoods.size();
        for (int i = 0; i < nCount; i++)
        {
            pFood = m_vCutFoods[i];
            if (pFood != NULL)
            {
                nIndex = pFood->getTouchedIndex();
                Vec2 v2Dest = convertToNodeSpace(m_pContentLayer->convertToWorldSpace(PANZI_POSITION[nIndex]));
                float fSpeed = 1200;
                float fDis = pFood->getPosition().distance(v2Dest);
                pFood->runAction(Sequence::create(DelayTime::create(0.08f * i),
                                                  MoveTo::create(fDis / fSpeed, v2Dest),
                                                  CallFunc::create([this, pFood, nCount, nIndex](){
                    static int nTmp = 0;
                    nTmp ++;
                    if (nTmp >= nCount)
                    {
                        nTmp = 0;
                        //todo: 在盘子上创建碎食材
                        std::vector<int> vMaterials = pFood->getMaterials();
                        MATERIAL_ID eId = MI_MAX;
                        if (vMaterials.size() != 0)
                        {
                            eId = (MATERIAL_ID)vMaterials[0];
                        }

                        int aTastes[TT_MAX] = {0};
                        CFoodPiece* pFoodPiece = CFoodPiece::create(eId);
                        if (pFoodPiece != NULL)
                        {
                            pFoodPiece->initProperty(FT_SUIPIAN, vMaterials, aTastes);
                            m_pContentLayer->addChild(pFoodPiece, 1);
                            pFoodPiece->setPosition(PANZI_POSITION[nIndex]);
                        }
                        
                        CGlobalData::getSingleton()->setPanziFood(pFood->getPanziIndex(), pFood);
                    }
                    
                    pFood->removeFromParent();
                }), NULL));
            }
        }
        m_vCutFoods.clear();
        m_bHasFood = false;
    }
}
开发者ID:GitofThunder,项目名称:gitskills,代码行数:55,代码来源:CutScene.cpp

示例11: ccp

void BBAbstractSceneView::onTouchScaleBegin(float nDistance, float nFocusX, float nFocusY)
{
	m_ptScaleBeginFocus = ccp(nFocusX, nFocusY);
	m_nScaleBeginScale = getScale();
	m_nScaleBeginDistance = nDistance;
	
	CCSize cs = getContentSize();
	m_ptScaleBeginFocusRate = convertToNodeSpace(m_ptScaleBeginFocus);
	m_ptScaleBeginFocusRate.x/=cs.width;
	m_ptScaleBeginFocusRate.y/=cs.height;
};
开发者ID:newcl,项目名称:boom,代码行数:11,代码来源:BBAbstractSceneView.cpp

示例12: onTouchesMoved

void ScrollViewDemo::onTouchesMoved(const std::vector<Touch*>& touches, Event  *event)
{
    if (!_scrolling) return;
	Touch *touch = touches[0];
    auto clipper = this->getChildByTag(kTagClipperNode);
    auto point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView()));
	Vec2 diff = point - _lastPoint;
    auto content = clipper->getChildByTag(kTagContentNode);
    content->setPosition(content->getPosition() + diff);
    _lastPoint = point;
}
开发者ID:anilgulgor,项目名称:myGame,代码行数:11,代码来源:ClippingNodeTest.cpp

示例13: getNodeRect

bool RCCheckButton::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
    bool bRet = false;
	CCRect checkBtnRect = getNodeRect();
	if(checkBtnRect.containsPoint(convertToNodeSpace(pTouch->getLocation())))
	{
		m_pText->setColor(m_selectedLabelColor);
		bRet = true;
	}
	return bRet;
}
开发者ID:ryanflees,项目名称:CocosbuilderDemo,代码行数:11,代码来源:RCCheckButton.cpp

示例14: convertToNodeSpace

bool Slider::onTouchBegan(Touch *touch, Event *unusedEvent)
{
    bool pass = Widget::onTouchBegan(touch, unusedEvent);
    if (_hitted)
    {
        Vec2 nsp = convertToNodeSpace(_touchBeganPosition);
        setPercent(getPercentWithBallPos(nsp.x));
        percentChangedEvent();
    }
    return pass;
}
开发者ID:Ratel13,项目名称:Cocos2dGame-v3.7,代码行数:11,代码来源:UISlider.cpp

示例15: convertToNodeSpace

bool Widget::hitTest(const Vec2 &pt)
{
    Vec2 nsp = convertToNodeSpace(pt);
    Rect bb;
    bb.size = _contentSize;
    if (bb.containsPoint(nsp))
    {
        return true;
    }
    return false;
}
开发者ID:AppleJDay,项目名称:cocos2d-x,代码行数:11,代码来源:UIWidget.cpp


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