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


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

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


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

示例1: ccTouchesEnded

void Clayer_normalMapped::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCSetIterator it;
    CCTouch* touch;
    
    for( it = touches->begin(); it != touches->end(); it++)
    {
        touch = (CCTouch*)(*it);
        
        if(!touch)
            break;
        
        CCPoint loc_winSpace = touch->getLocationInView();
        CCPoint loc_GLSpace = CCDirector::sharedDirector()->convertToGL(loc_winSpace);
        
        m_lightSprite->setPosition(loc_GLSpace);
        
    }
}
开发者ID:Eason-Xi,项目名称:EffectNodes-for-cocos2dx,代码行数:21,代码来源:layer_normalMapped.cpp

示例2: ccTouchesMoved

void GameWorld::ccTouchesMoved(CCSet* set, CCEvent* event)
{
	// don't accept touch when clown is in these states
	if(clown_->GetState() == E_CLOWN_ROCKET ||
		clown_->GetState() == E_CLOWN_BALLOON ||
		clown_->GetState() == E_CLOWN_UP)
		return;

	CCTouch* touch = (CCTouch*)(*set->begin());
	CCPoint touch_point = touch->getLocationInView();
	touch_end_ = CCDirector::sharedDirector()->convertToGL(touch_point);

	// manipulate anchor point so the platform is correctly oriented
	platform_->setAnchorPoint( touch_end_.x >= touch_start_.x ? ccp(0, 0.5f) : ccp(1, 0.5f) );
	float length = ccpDistance(touch_end_, touch_start_);
	// scale the platform according to user input
	platform_->setScaleX(length / platform_->getContentSize().width);
	// manipulate rotation so that platform doesn't appear upside down
	float angle = CC_RADIANS_TO_DEGREES(-1 * ccpToAngle(ccpSub(touch_end_, touch_start_)));
	platform_->setRotation( touch_end_.x >= touch_start_.x ? angle : angle + 180 );
}
开发者ID:karanseq,项目名称:JumpyClown,代码行数:21,代码来源:GameWorld.cpp

示例3: ccTouchesMoved

void HelloWorld::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
	CCTouch *touch = (CCTouch *)pTouches->anyObject();
	CCPoint pointTouched = touch->getLocationInView();
	pointTouched = CCDirector::sharedDirector()->convertToGL(pointTouched);

	if (pointTouched.x <= moveSize)
	{
		smallcircle->setVisible(true);
		bigcircle->setVisible(true);
		smallcircle->setPosition(pointTouched);
		m_IsTouchMoved = true;
		IsHolding = false;
	}
	else 
	{
		smallcircle->setVisible(false);
		bigcircle->setVisible(false);
		m_IsTouchMoved = false;
	}
}
开发者ID:vinova-summer-school,项目名称:vss2013-04_battle-tank,代码行数:21,代码来源:Touched.cpp

示例4: ccTouchesBegan

void HelloWorld::ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent) {
    
    // touch
    CCTouch *touch = (CCTouch *)pTouches->anyObject();
    CCPoint location = touch->getLocationInView();
    location = CCDirector::sharedDirector()->convertToGL(location);
    CCLog("---location (%f, %f)", location.x, location.y);
    
    /*
    // Test Messaging
    MessageDispatcher::instance()->dispatchMessage(0, 0, 0, kTesting, (void *)"Hello World");
     */
    
    /*
    // Test Collision
    Fighter *newFighter = Fighter::create(kPeasant);
    m_pBatch->addChild(newFighter->getSprite());
    
    newFighter->setPosition(location);
     */
}
开发者ID:adahera222,项目名称:Samurai-TD,代码行数:21,代码来源:HelloWorldScene.cpp

示例5: ccTouchesBegan

void CtestLayer::ccTouchesBegan(CCSet* touches, CCEvent* event)
{
    
    CCSetIterator it;
    CCTouch* touch;
	for( it = touches->begin(); it != touches->end(); it++)
    {
        touch = (CCTouch*)(*it);
        if(!touch)
            break;
        
        CCPoint pointInWinSpace = touch->getLocationInView();
        //note: for 3d mode, CCDirector::convertToGL() not works as we expected
        //  CCPoint pointInWinSpace = CCDirector::sharedDirector()->convertToGL(pointInWinSpace);
        
        //----update mos
        m_mosPosf=m_mosPos;
        m_mosPos=pointInWinSpace;
        
    }
}
开发者ID:liqt,项目名称:3DToolKit-2-for-cocos2dx,代码行数:21,代码来源:testLayer.cpp

示例6: onTouchesBegan

void Clayer_break:: onTouchesBegan(const std::vector<Touch*>& touches, Event *unused_event)
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
     
    CCTouch* touch;
	for(auto  it = touches.begin(); it != touches.end(); it++)
    {
        touch = (CCTouch*)(*it);
        if(!touch)
            break;
        
        CCPoint loc_winSpace = touch->getLocationInView();
        CCPoint loc_GLSpace = CCDirector::sharedDirector()->convertToGL(loc_winSpace);
        //CCLOG("loc_GLSpace:%f,%f",loc_GLSpace.x,loc_GLSpace.y);
        
        
        switch (m_breakSprite->getState()) {
            case ens::breakEffect::eState_well:
                m_breakSprite->doCrack(loc_GLSpace);
                break;
            case ens::breakEffect::eState_crack:
            {
                m_breakSprite->generateDelayTimes(15);
                breakEffect::CfallOffAction*breakAction=breakEffect::CfallOffAction::create(30);
                m_breakSprite->runAction(breakAction);
            }
                break;
            case ens::breakEffect::eState_fallOff:
                m_breakSprite->reSet();
                break;
            default:
                break;
        }
        
        break;
        
        
    }
}
开发者ID:hujinheng,项目名称:gameProject,代码行数:40,代码来源:layer_break.cpp

示例7: ccTouchesBegan

void GameLayer::ccTouchesBegan(CCSet* touches, CCEvent* event)
{
    if(_gameStrategy->getGameStatus() == GAME_OVER) {
        CCScene* mainScene = Main::scene();
        CCDirector::sharedDirector()->replaceScene(mainScene);
        return;
    }
    
    CCTouch *touch = (CCTouch*) touches->anyObject();
    CCPoint location = touch->getLocationInView();
    location = CCDirector::sharedDirector()->convertToGL(location);
    
    if(_pauseButton->getPosition().x >= location.x &&
       _pauseButton->getPosition().x - _pauseButton->getContentSize().width <= location.x &&
       _pauseButton->getPosition().y >= location.y &&
       _pauseButton->getPosition().y - _pauseButton->getContentSize().height <= location.y) {
        if(_gameStrategy->getGameStatus() == PAUSE) {
            _gameStrategy->resumeGame();
            _pauseButton->setNormalMode();
        } else if(_gameStrategy->getGameStatus() == IN_PROCESS) {
            _gameStrategy->pauseGame();
            _pauseButton->setClickedMode();
        }
        return;
    }
    
    if(_gameStrategy->isPaused()) return;
    if(_abilityButton->getPosition().x + _abilityButton->_panelSprite->getContentSize().width / 2 >= location.x &&
       _abilityButton->getPosition().x - _abilityButton->_panelSprite->getContentSize().width / 2 <= location.x &&
       _abilityButton->getPosition().y + _abilityButton->_panelSprite->getContentSize().height / 2 >= location.y &&
       _abilityButton->getPosition().y - _abilityButton->_panelSprite->getContentSize().height / 2 <= location.y) {
        if(_abilityButton->isReady()) {
            _gameStrategy->useAbility();
            return;
        }
    }
        
    _gameStrategy->touchesBegan(touches, event);
}
开发者ID:DmitriyKirakosyan,项目名称:spaceUnitIOS,代码行数:39,代码来源:GameScene.cpp

示例8: ccTouchesBegan

// タッチダウン
void HelloWorld::ccTouchesBegan(CCSet* touches, CCEvent* event)
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    //Add a new body/atlas sprite at the touched location
    CCSetIterator it;
    CCTouch* touch;

    for( it = touches->begin(); it != touches->end(); it++)
    {
        touch = (CCTouch*)(*it);
        
        if(!touch)
            break;
        
        CCPoint location = touch->getLocationInView();
        location = CCDirector::sharedDirector()->convertToGL(location);
        
        // マウスジョイント取得
        mouseJoint = this->getMouseJoint(location);
    }
}
开发者ID:ytworks,项目名称:private,代码行数:23,代码来源:HelloWorldScene.cpp

示例9: ccTouchesEnded

void HelloWorld::ccTouchesEnded(CCSet *pTouches,CCEvent *pEvent)
{
	//获取鼠标位置
	CCTouch *touch = (CCTouch*)pTouches->anyObject();
	CCPoint locInView= touch->getLocationInView();
	//坐标系的转化
	CCPoint loc =CCDirector::sharedDirector()->convertToGL(locInView);

	//精灵的动作
	//CCCallFuncN* disapear= CCCallFuncN::create(this,callfuncN_selector(HelloWorld::myDefine));
	for(vector<keyedit*>::iterator it=this->m_pSpriteList.begin();it!=m_pSpriteList.end();it++){
		if(isTouchGetNode(*it,touch)){
			(*it)->endTime = getCurrentTime();
			(*it)->Change();
			(*it)->isClick = true;
			currentScore+=5;
			CCLOG("currentScore:%d",currentScore);
			break;
		}
	}
	//mykey->runAction(disapear);
}
开发者ID:Wuhzz,项目名称:0,代码行数:22,代码来源:HelloWorldScene.cpp

示例10: ccTouchesBegan

void GameScene::ccTouchesBegan(CCSet* touches, CCEvent* event)
{
	// Choose one of the touches to work with
	CCTouch* touch = (CCTouch*)( touches->anyObject() );
	CCPoint location = touch->getLocationInView();
	location = CCDirector::sharedDirector()->convertToGL(location);

	if ( _ledsSelected->count() > 0 and _palette->boundingBox().containsPoint(location) )
	{
		int locX = location.x;
		int locY = location.y;
		CCLOG("X:%d Y:%d", locX, locY);
		int red = (locX / 72) * 36;
		int green = 255 - ( (locY / 18) * 36 );
		int blue = ( (locX % 64) / 16) * 85;

		CCObject *it = NULL;
		CCARRAY_FOREACH(_ledsSelected, it)
		{
			CCMenuItem *led = dynamic_cast<CCMenuItem*>(it);
			led->setColor( ccc3(red, green, blue) );
		}
开发者ID:juaniiton1,项目名称:PFC,代码行数:22,代码来源:GameScene.cpp

示例11: onTouchesMoved

void Clayer_tail::onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event)
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
     
    CCTouch* touch;
    for(auto  it = touches.begin(); it != touches.end(); it++)
    {
        touch = (CCTouch*)(*it);
        
        if(!touch)
            break;
        
        CCPoint loc_winSpace = touch->getLocationInView();
        CCPoint loc_GLSpace = CCDirector::sharedDirector()->convertToGL(loc_winSpace);
        

         if(m_tailSpriteList.empty()==false)m_tailSpriteList[(int)m_tailSpriteList.size()-1]->setPosition(loc_GLSpace);
		
    }
    
}
开发者ID:propros,项目名称:effectnode,代码行数:22,代码来源:layer_tail.cpp

示例12: ccTouchesMoved

void Clayer_tail::ccTouchesMoved(cocos2d::CCSet* touches , cocos2d::CCEvent* event)
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCSetIterator it;
    CCTouch* touch;
    for( it = touches->begin(); it != touches->end(); it++)
    {
        touch = (CCTouch*)(*it);
        
        if(!touch)
            break;
        
        CCPoint loc_winSpace = touch->getLocationInView();
        CCPoint loc_GLSpace = CCDirector::sharedDirector()->convertToGL(loc_winSpace);
        

         if(m_tailSpriteList.empty()==false)m_tailSpriteList[(int)m_tailSpriteList.size()-1]->setPosition(loc_GLSpace);
		
    }
    
}
开发者ID:JoeHu,项目名称:EffectNodes-for-cocos2dx,代码行数:22,代码来源:layer_tail.cpp

示例13: ccTouchesBegan

void HelloWorld::ccTouchesBegan(CCSet* touches, CCEvent* even)
{
    if (m_mouseJoint != NULL)
    {
        return;
    }
    
    CCTouch *touch = (CCTouch *)touches->anyObject();
    CCPoint location = touch->getLocationInView();
    location = CCDirector::sharedDirector()->convertToGL(location);
    b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);
    if (locationWorld.x < m_armBody->GetWorldCenter().x + 150.0/PTM_RATIO)
    {
        b2MouseJointDef md;
        md.bodyA = groundBody;
        md.bodyB = m_armBody;
        md.target = locationWorld;//设置鼠标的单机点
        md.maxForce = 2000;
        
        m_mouseJoint = (b2MouseJoint *)world->CreateJoint(&md);
    }
    
}
开发者ID:YanglongjunLAX,项目名称:cocos2d-x_study,代码行数:23,代码来源:HelloWorldScene.cpp

示例14: ccTouchesBegan

void HelloWorld::ccTouchesBegan(CCSet* touches, CCEvent *event)
{
	start = true;
	if(mouseJoint != nullptr)
		return;

	CCTouch* touch = (CCTouch*)(touches->anyObject());
	touches->count();
	CCPoint location = touch->getLocationInView();
	location = CCDirector::sharedDirector()->convertToGL(location);
	b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);
	if(locationWorld.x < armBody->GetWorldCenter().x + 50.0/PTM_RATIO)
	{
		b2MouseJointDef md;
		md.bodyA = groundBody;
		md.bodyB = armBody;
		md.target = locationWorld;
		md.maxForce = 2000;

		mouseJoint = (b2MouseJoint *)world->CreateJoint(&md);
		printf("asdf");
	}
}
开发者ID:GhostSoar,项目名称:Cocos2dWindows,代码行数:23,代码来源:HelloWorldScene.cpp

示例15: ccTouchesCancelled

void Game::ccTouchesCancelled(cocos2d::CCSet *touches, cocos2d::CCEvent *event)
{
    int touchCount = 0;
    
    for(CCSetIterator i = touches->begin(); i != touches->end(); i ++)
    {
        CCTouch* t = (CCTouch*)(*i);
        CCPoint location = t->getLocationInView();
        location = CCDirector::sharedDirector()->convertToGL(location);
        
        location += touchOffset;
        
        touch[t->m_uID].position = location * scaleFactor;
        touch[t->m_uID].held = false;
        touch[t->m_uID].newPress = false;
        touch[t->m_uID].released = true;
        touch[t->m_uID].enabled = false;
        
        touchCount++;
    }
    
    updateTouches();
}
开发者ID:birslip,项目名称:Blood-Vessel,代码行数:23,代码来源:Game.cpp


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