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


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

本文整理汇总了C++中CCTouch::view方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTouch::view方法的具体用法?C++ CCTouch::view怎么用?C++ CCTouch::view使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCTouch的用法示例。


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

示例1: nodeForTouch

GestureRecognizer* GestureRecognizer::nodeForTouch(CCSet *pTouches)
{
    CCSetIterator it;
    
    for( it = pTouches->begin(); it != pTouches->end(); ++it)
    {
        if (*it)
        {
            CCTouch *touch = (CCTouch *)*it;
            CCPoint touchLocation = touch->locationInView(touch->view());
            touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);

            if (!m_pNode)
                break;
            
            if (m_pNode->getIsVisible() && m_pNode->getTouchEnabled())
            {
                CCPoint local = m_pNode->convertToNodeSpace(touchLocation);
                CCRect r = m_pNode->nodeRect();
                r.origin = CCPointZero;
                
                if (CCRect::CCRectContainsPoint(r, local))
                {
                    this->setTouchView(touch->view());
                    return this;
                }
            }
        }
    }
    
    return NULL;
}
开发者ID:nthtran-archive,项目名称:EPlibs,代码行数:32,代码来源:GestureRecognizer.cpp

示例2: ccTouchesMoved

void GLayer::ccTouchesMoved(CCSet* pTouches, CCEvent* event)
{
	if( smpModalInterface )
	{
		GnInterfacePtr ptr = smpModalInterface;
		for( CCSetIterator it = pTouches->begin(); it != pTouches->end(); ++it )
		{
			CCTouch* touch = (CCTouch*)(*it);
			CCPoint touchPoint = touch->locationInView( touch->view() );
			ptr->PushMove( touchPoint.x, touchPoint.y );
		}
		return;
	}
	for( CCSetIterator it = pTouches->begin(); it != pTouches->end(); ++it )
	{
		CCTouch* touch = (CCTouch*)(*it);
		CCPoint touchPoint = touch->locationInView( touch->view() );
		for ( gtuint i = 0 ; i < mInterfaceChildren.GetSize(); i++ )
		{
			GnInterface* child = mInterfaceChildren.GetAt( i );
			if( touch == child->GetCurrentTouch() )
				child->PushMove( touchPoint.x, touchPoint.y );
		}
	}
}
开发者ID:daoopp,项目名称:WebGame,代码行数:25,代码来源:GLayer.cpp

示例3: 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

示例4: ccTouchesEnded

void MainLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
    CCSetIterator it = pTouches->begin();
	CCTouch* touch = (CCTouch*)(*it);
	
	CCPoint location = touch->locationInView( touch->view() );
	CCPoint convertedLocation = CCDirector::sharedDirector()->convertToGL(location);

	CCNode* s = getChildByTag(kTagSprite);
	s->stopAllActions();
	s->runAction( CCMoveTo::actionWithDuration(1, CCPointMake(convertedLocation.x, convertedLocation.y) ) );
	float o = convertedLocation.x - s->getPosition().x;
	float a = convertedLocation.y - s->getPosition().y;
	float at = (float) CC_RADIANS_TO_DEGREES( atanf( o/a) );
	
	if( a < 0 ) 
	{
		if(  o < 0 )
			at = 180 + fabs(at);
		else
			at = 180 - fabs(at);	
	}
	
	s->runAction( CCRotateTo::actionWithDuration(1, at) );
}
开发者ID:Bahamut,项目名称:cocos2d-x,代码行数:25,代码来源:ClickAndMoveTest.cpp

示例5: ccTouchesBegan

//-------------------------------------------------------------------------------
//
//
void CMiniGameCatchLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
	if( m_bIsHit )
	{
		return;
	}

    CCSetIterator it = pTouches->begin();
	CCTouch* touch = (CCTouch*)(*it);
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCPoint touchLocation = touch->locationInView( touch->view() );
	touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
    
    if( touchLocation.x  < m_pPet->getPosition().x )
    {
         m_iPetActionState = MINIGAME_PET_MOVE_LEFT;
    }
    else if( touchLocation.x > m_pPet->getPosition().x )
    {
         m_iPetActionState = MINIGAME_PET_MOVE_RIGHT;
    }
     m_pPet->PlayAnimation( m_pBaseDataAnimation->m_move, -1, NULL, this, false, false);
   
    
    std::string effectpath = GetGameParticlePath();
    std::string filename = effectpath + "touchDownEffect.plist";
    CCParticleSystemQuad *pEmitter = CCParticleSystemQuad::particleWithFile( filename.c_str() );
    pEmitter->setPosition( touchLocation );
    CCPoint pos = getPosition();
    addChild( pEmitter, 100 );
  
}
开发者ID:jonesgithub,项目名称:magicpet,代码行数:36,代码来源:CMiniGameCatchLayer.cpp

示例6: ccTouchesBegan

void SFCoinsGameScene::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent){
    
    if(box->isLocked())
        return;
	CCSetIterator it = pTouches->begin();
    CCTouch* touch = (CCTouch*)(*it);
    CCPoint location = touch->locationInView(touch->view());
    location = CCDirector::sharedDirector()->convertToGL( location );
    
    int x = (location.x -kStartX) / kTileSize;
	int y = (location.y -kStartY) / kTileSize;
	
	if (selectedTile && selectedTile->x ==x && selectedTile->y == y)
		return;
    SFGameTile *tile = box->objectAtXAndY(x, y);
    
    if(selectedTile && selectedTile->nearTile(tile))
    {
        box->setLock(true);
        this->changeWithTileABandSel(selectedTile, tile, callfuncND_selector(SFCoinsGameScene::checkSenderandData));
        selectedTile = NULL;
    }
    else
    {
        selectedTile = tile;
        this->afterOneShineTrun(tile->sprite);
    }
}
开发者ID:DavidYangNO1,项目名称:Shake-Food,代码行数:28,代码来源:SFCoinsGameScene.cpp

示例7: ccTouchesMoved

void MapScene::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
    CCSetIterator it = pTouches->begin();
    CCTouch* touch = (CCTouch*)(*it);

    CCPoint m_tBeginPos = touch->locationInView( touch->view() );
    m_tBeginPos = CCDirector::sharedDirector()->convertToGL( m_tBeginPos );

    float angle = 0 ;
    CCPoint direct = rocker1->getDirection();
    if (vectorLength(direct) > 0.01f)
    {
        direct.x -= 2 * direct.x;
        direct.y -= 2 * direct.y;
        angle = atan2(direct.y, direct.x);
        if (angle >= -0.001f)
        {
            angle = 360 - 180 * (angle / PI);
        }
        else
        {
            angle = (-1)  * 180 * (angle / PI);
        }

        if (fabs(player->pAngle - angle) > 3)
        {

            player->getsprite()->setRotation(angle);
            player->pAngle = angle;

        }

    }
}
开发者ID:hustpawpaw,项目名称:Cocos2dDemo,代码行数:34,代码来源:MapScene.cpp

示例8: ccTouchesEnded

void RenderTextureTest::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
#if CC_ENABLE_CACHE_TEXTTURE_DATA

	CCSetIterator it;
	CCTouch* touch;

	for( it = touches->begin(); it != touches->end(); it++) 
	{
		touch = (CCTouch*)(*it);

		if(!touch)
			break;

		CCPoint location = touch->locationInView(touch->view());

		location = CCDirector::sharedDirector()->convertToGL(location);

		m_brush->setPosition(location);
		m_brush->setRotation( rand()%360 );
	}

	m_target->begin();
	m_brush->visit();
	m_target->end(true);
#endif
}
开发者ID:BGCX261,项目名称:zombieswarmer-svn-to-git,代码行数:27,代码来源:RenderTextureTest.cpp

示例9: 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

示例10: 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

示例11: ccTouchesBegan

void TestController::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
    stopAllActions();
    CCDelayTime* delaytime = CCDelayTime::actionWithDuration(0.2);
    delaytime->setTag(99);
    this->runAction(delaytime);
    CCSetIterator it = pTouches->begin();
    CCTouch* touch = (CCTouch*)(*it);
    m_tBeginPos = touch->locationInView(touch->view());
}
开发者ID:Openxlive,项目名称:cocos2d-x-win8-tests-metro-style,代码行数:10,代码来源:controller.cpp

示例12: ccTouchesMoved

void HelloWorld::ccTouchesMoved(CCSet* touches, CCEvent* event)
{
    if (_mouseJoint == NULL) return;
    
    CCTouch *myTouch = (CCTouch *)touches->anyObject();
    CCPoint location = myTouch->locationInView(myTouch->view());
    location = CCDirector::sharedDirector()->convertToGL(location);
    b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);

    _mouseJoint->SetTarget(locationWorld);
}
开发者ID:vincetran,项目名称:NyanBreak,代码行数:11,代码来源:HelloWorldScene.cpp

示例13: ccTouchesMoved

void HelloWorld::ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
{
    if (mouseJoint == NULL) return;
    
    CCTouch *myTouch = (CCTouch *) pTouches->anyObject();
    CCPoint location = myTouch->locationInView(myTouch->view());
    location = CCDirector::sharedDirector()->convertToGL(location);
    b2Vec2 locationWorld = b2Vec2(location.x/ptmRatio, location.y/ptmRatio);

    mouseJoint->SetTarget(locationWorld);
}
开发者ID:Menki,项目名称:Breakout,代码行数:11,代码来源:HelloWorldScene.cpp

示例14: findTouch

CCTouch* CCEGLView::findTouch(int id) 
{
    CCSetIterator iter;
	for (iter = m_pSet->begin(); iter != m_pSet->end(); ++iter)
	{
        CCTouch *touch = (CCTouch*)*iter;
                
		if(touch->view() == id)
            return touch;
	}
    
    return NULL;
}
开发者ID:KerwinMa,项目名称:NDRemoteTest,代码行数:13,代码来源:CCEGLView_marmalade.cpp

示例15: ccTouchesEnded

// cpp with cocos2d-x
void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
	// Choose one of the touches to work with
	CCTouch* touch = (CCTouch*)( touches->anyObject() );
	CCPoint location = touch->locationInView(touch->view());

	location = CCDirector::sharedDirector()->convertToGL(location);

	// Set up initial location of projectile
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CCSprite *projectile = CCSprite::spriteWithFile("Projectile.png", 
		CCRectMake(0, 0, 20, 20));
	projectile->setPosition( ccp(20, winSize.height/2) );

	// Determinie offset of location to projectile
	float offX = location.x - projectile->getPosition().x;
	float offY = location.y - projectile->getPosition().y;

	// Bail out if we are shooting down or backwards
	if (offX <= 0) return;

	// Ok to add now - we've double checked position
	this->addChild(projectile);

	// Determine where we wish to shoot the projectile to
	float realX = winSize.width + (projectile->getContentSize().width/2);
	float ratio = offY / offX;
	float realY = (realX * ratio) + projectile->getPosition().y;
	CCPoint realDest = ccp(realX, realY);

	// Determine the length of how far we're shooting
	float offRealX = realX - projectile->getPosition().x;
	float offRealY = realY - projectile->getPosition().y;
	float length = sqrtf((offRealX * offRealX) + (offRealY*offRealY));
	float velocity = 480/1; // 480pixels/1sec
	float realMoveDuration = length/velocity;

	// Move projectile to actual endpoint
	projectile->runAction( CCSequence::actions(
		CCMoveTo::actionWithDuration(realMoveDuration, realDest),
		CCCallFuncN::actionWithTarget(this, 

		callfuncN_selector(HelloWorld::spriteMoveFinished)), 
		NULL) );

	// Add to projectiles array
	projectile->setTag(2);
	_projectiles->addObject(projectile);

	CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("pew-pew-lei.wav");
}
开发者ID:Ancool,项目名称:Cocos2dxSimpleGame,代码行数:52,代码来源:HelloWorldScene.cpp


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