本文整理汇总了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;
}
示例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 );
}
}
}
示例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));
}
示例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) );
}
示例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 );
}
示例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);
}
}
示例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;
}
}
}
示例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
}
示例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 );
}
}
示例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 );
}
}
示例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());
}
示例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);
}
示例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);
}
示例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;
}
示例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");
}