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


C++ CCTouch::previousLocationInView方法代码示例

本文整理汇总了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)));
}
开发者ID:x007th,项目名称:2d-xDemo,代码行数:15,代码来源:MainLayer.cpp

示例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));
}
开发者ID:Openxlive,项目名称:cocos2d-x-win8-tests-metro-style,代码行数:15,代码来源:controller.cpp

示例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 );
	}


}
开发者ID:JoeHu,项目名称:magicpet,代码行数:46,代码来源:CMiniGameGamblingLayer.cpp

示例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 );

	}


}
开发者ID:JoeHu,项目名称:magicpet,代码行数:46,代码来源:CTaskEventSubGui.cpp

示例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();
}
开发者ID:BGCX261,项目名称:zombieswarmer-svn-to-git,代码行数:36,代码来源:RenderTextureTest.cpp


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