cocos2d-x Tests講解一:Tests的整體架構
阿新 • • 發佈:2019-02-07
{
CCSetIterator it = pTouches->begin();
CCTouch* touch = (CCTouch*)(*it);
CCPoint touchLocation = touch->locationInView( touch->view() );
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
float nMoveY = touchLocation.y - m_tBeginPos.y;
CCPoint curPos = m_pItemMenu->getPosition();
CCPoint nextPos = ccp(curPos.x, curPos.y + nMoveY);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
if (nextPos.y < 0.0f)
{
m_pItemMenu->setPosition(CCPointZero);
return;
}
if (nextPos.y > ((TESTS_COUNT + 1)* LINE_SPACE - winSize.height))
{
m_pItemMenu->setPosition(ccp(0, ((TESTS_COUNT + 1)* LINE_SPACE - winSize.height)));
return;
}
m_pItemMenu->setPosition(nextPos);
m_tBeginPos = touchLocation;
s_tCurPos = nextPos;
}
CCSetIterator it = pTouches->begin();
CCTouch* touch = (CCTouch*)(*it);
CCPoint touchLocation = touch->locationInView( touch->view() );
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
float nMoveY = touchLocation.y - m_tBeginPos.y;
CCPoint curPos = m_pItemMenu->getPosition();
CCPoint nextPos = ccp(curPos.x, curPos.y + nMoveY);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
if
{
m_pItemMenu->setPosition(CCPointZero);
return;
}
if (nextPos.y > ((TESTS_COUNT + 1)* LINE_SPACE - winSize.height))
{
m_pItemMenu->setPosition(ccp(0, ((TESTS_COUNT + 1)* LINE_SPACE - winSize.height)));
return;
}
m_pItemMenu->setPosition(nextPos);
m_tBeginPos = touchLocation;
s_tCurPos = nextPos;
}