本文整理汇总了C++中CCTouch::previousLocationInView方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTouch::previousLocationInView方法的具体用法?C++ CCTouch::previousLocationInView怎么用?C++ CCTouch::previousLocationInView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTouch
的用法示例。
在下文中一共展示了CCTouch::previousLocationInView方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ccTouchesMoved
void MainLayer::ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent){
CCTouch* pTouch = (CCTouch*)pTouches->anyObject();
CCPoint touchPoint = pTouch->locationInView();
touchPoint = CCDirector::sharedDirector()->convertToGL(touchPoint);
CCPoint oldPoint = pTouch->previousLocationInView();
oldPoint = CCDirector::sharedDirector()->convertToGL(oldPoint);
CCPoint translation = ccpSub(touchPoint, oldPoint);
CCPoint newPos = ccpAdd(this->getPosition(), translation);
CCPoint oldPos = this->getPosition();
this->setPosition(boundLayerPos(newPos));
m_emitter->setPosition(ccpSub(m_emitter->getPosition(), ccpSub(boundLayerPos(newPos), oldPos)));
}
示例2: ccTouchesMoved
void TestController::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
CCSetIterator it = pTouches->begin();
CCTouch* touch = (CCTouch*)(*it);
CCPoint p1 = touch->previousLocationInView(touch->view());
CCPoint p2 = touch->locationInView(touch->view());
CCSize size = CCDirector::sharedDirector()->getWinSize();
float x = m_pItmeMenu->getPosition().x + (p2.x - p1.x) * 2;
if(x>= 0)
x = 0;
else if(x <= -m_pItmeMenu->getContentSize().width)
x = -m_pItmeMenu->getContentSize().width;
m_pItmeMenu->setPosition(CCPointMake(x,0));
}
示例3: ccTouchesEnded
//-----------------------------------------------------------
//
//
void CMiniGameGamblingLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
if( g_pPetDataBlock->petmoney < 200 )
{
string utf81,utf82;
CChineseCode::GB2312ToUTF_8( utf81, (char*)message_nomoney[g_iCurLanguageIndex], 256 );
CChineseCode::GB2312ToUTF_8( utf82, (char*)message_tip[g_iCurLanguageIndex], 256 );
CMessageBoxYes *pMessage= new CMessageBoxYes( (char*)utf81.c_str(), (char*)utf82.c_str(), NULL, NULL );
pMessage->autorelease();
CCDirector::sharedDirector()->getRunningScene() ->addChild( pMessage, 100 );
return;
}
if( m_bIsTouch )
{
return;
}
CCSetIterator it = pTouches->begin();
CCTouch* touch = (CCTouch*)(*it);
CCPoint touchLocation = touch->locationInView( touch->view() );
CCPoint prevLocation = touch->previousLocationInView( touch->view() );
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
prevLocation = CCDirector::sharedDirector()->convertToGL( prevLocation );
CCPoint pos = convertTouchToNodeSpace( touch );
CCPoint menuPos = m_pPushBar->getPosition();
if( CCRect::CCRectContainsPoint( CCRect( menuPos.x - 32, menuPos.y, 480 / 2, 320 / 2 ), pos ) )
{
CCActionInterval *pInterval = CCRotateBy::actionWithDuration( 0.5, 60 );
CCActionInterval *pInterval2 = CCRotateBy::actionWithDuration( 0.5, -60 );
m_pPushBar->runAction( CCSequence::actions( pInterval, pInterval2, CCCallFuncND::actionWithTarget( this, callfuncND_selector( CMiniGameGamblingLayer::TouchCallBack ), NULL ), NULL ) );
m_bIsTouch = true;
schedule(schedule_selector(CMiniGameGamblingLayer::scheculePauseData), 0.1 );
}
}
示例4: ccTouchesMoved
//-------------------------------------------------------------------------
//
//
void CTaskEventSubGui::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
if( m_vTaskEvent.size() <= 4 )
{
m_pUpScorl->setIsVisible( false );
m_pDownScorl->setIsVisible( false );
return;
}
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCSetIterator it = pTouches->begin();
CCTouch* touch = (CCTouch*)(*it);
CCPoint touchLocation = touch->locationInView( touch->view() );
CCPoint prevLocation = touch->previousLocationInView( touch->view() );
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
prevLocation = CCDirector::sharedDirector()->convertToGL( prevLocation );
CCPoint diff = ccpSub(touchLocation, prevLocation);
CCPoint currentPos = m_pGroupNode->getPosition();
m_pGroupNode->setPosition( ccp( currentPos.x, ccpAdd(currentPos, diff).y ) );
m_pUpScorl->setIsVisible( true );
m_pDownScorl->setIsVisible( true );
if( m_pGroupNode->getPosition().y <= 0 )
{
m_pGroupNode->setPosition( ccp( m_pGroupNode->getPosition().x, 0 ) );
m_pUpScorl->setIsVisible( false );
}
if( m_pGroupNode->getPosition().y >= m_iEachSizeDis * ( m_vTaskEvent.size() - 4) )
{
m_pGroupNode->setPosition( ccp( m_pGroupNode->getPosition().x, m_iEachSizeDis * ( m_vTaskEvent.size() - 4) ) );
m_pDownScorl->setIsVisible( false );
}
}
示例5: ccTouchesMoved
void RenderTextureSave::ccTouchesMoved(CCSet* touches, CCEvent* event)
{
CCTouch *touch = (CCTouch *)touches->anyObject();
CCPoint start = touch->locationInView(touch->view());
start = CCDirector::sharedDirector()->convertToGL(start);
CCPoint end = touch->previousLocationInView(touch->view());
// begin drawing to the render texture
m_pTarget->begin();
// for extra points, we'll draw this smoothly from the last position and vary the sprite's
// scale/rotation/offset
float distance = ccpDistance(start, end);
if (distance > 1)
{
int d = (int)distance;
for (int i = 0; i < d; i++)
{
float difx = end.x - start.x;
float dify = end.y - start.y;
float delta = (float)i / distance;
m_pBrush->setPosition(ccp(start.x + (difx * delta), start.y + (dify * delta)));
m_pBrush->setRotation(rand() % 360);
float r = (float)(rand() % 50 / 50.f) + 0.25f;
m_pBrush->setScale(r);
/*m_pBrush->setColor(ccc3(CCRANDOM_0_1() * 127 + 128, 255, 255));*/
// Use CCRANDOM_0_1() will cause error when loading libtests.so on android, I don't know why.
m_pBrush->setColor(ccc3(rand() % 127 + 128, 255, 255));
// Call visit to draw the brush, don't call draw..
m_pBrush->visit();
}
}
// finish drawing and return context back to the screen
m_pTarget->end();
}