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


C++ CCTouch类代码示例

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


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

示例1: OnPointerOff

void CCTouchDispatcher::OnPointerOff(const InputPointerEvent* evt)
{
	map<Ref<InputPointer>, CCTouch*>::type::iterator itr = m_Touches.find(evt->getSource());
	if (itr == m_Touches.end())
		return;

	CCSet set;
	CCTouch* pTouch = itr->second;
	m_Touches.erase(itr);

	pTouch->SetTouchInfo(0, evt->getPos().x, evt->getPos().y);

	set.addObject(pTouch);

//  	LOG(0, ".. off %.3f %.3f\n", evt->GetPos().x, evt->GetPos().y);

	touchesEnded(&set);

	pTouch->release();
}
开发者ID:noriter,项目名称:nit,代码行数:20,代码来源:CCTouchDispatcher.cpp

示例2: onTouchesMoved

void Clayer_ripple_horizontal::onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event)
{
     
    CCTouch* touch;
    for(auto  it = touches.begin(); it != touches.end(); it++)
    {
        touch = (CCTouch*)(*it);
        
        if(!touch)
            break;
        
        CCPoint location = touch->getLocationInView();
        
        location = CCDirector::sharedDirector()->convertToGL(location);
        //    cout<<"mos pos:"<<location.x<<" "<<location.y<<endl;
   m_ripple_horizontalNode->pressAtX(location.x, 0.8);
        break;
    }
    
}
开发者ID:propros,项目名称:effectnode,代码行数:20,代码来源:layer_ripple_horizontal.cpp

示例3: ccTouchesBegan

void HudLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) {
	if (Utils::gameLayer()->getState() == kEditMode) {
	    CCTouch *pTouch;
	    CCSetIterator setIter;
	    for (setIter = pTouches->begin(); setIter != pTouches->end(); ++setIter) {
	        pTouch = (CCTouch *)(*setIter);
	        _touches->addObject(pTouch);
	    }
	    pTouch = (CCTouch *) _touches->objectAtIndex(0);
		CCPoint location = pTouch->getLocation();

		for (int i = 0; i < _tools->count(); i++) {
			Tool *tool = (Tool *) _tools->objectAtIndex(i);
			if (tool->touchingTool(location)) {
				_movingTool = i;
				Utils::gameLayer()->setShouldPan(false);
			}
		}
	}
}
开发者ID:jackmichel,项目名称:Elis-Escape,代码行数:20,代码来源:HudLayer.cpp

示例4: OnPenDown

Boolean CCEGLView::OnPenDown(EventType* pEvent, Int32 nIndex)
{
    if (m_pDelegate && nIndex < MAX_TOUCHES)
    {
        CCTouch* pTouch = s_pTouches[nIndex];
        if (!pTouch)
        {
            pTouch = new CCTouch;
        }

        pTouch->SetTouchInfo(0, (float)(pEvent->sParam1 - m_rcViewPort.X()) / m_fScreenScaleFactor,
                             (float)(pEvent->sParam2 - m_rcViewPort.Y()) / m_fScreenScaleFactor);
        s_pTouches[nIndex] = pTouch;
        CCSet set;
        set.addObject(pTouch);
        m_pDelegate->touchesBegan(&set, NULL);
    }

    return FALSE;
}
开发者ID:flyingpacer,项目名称:cocos2d-x-samples,代码行数:20,代码来源:CCEGLView_wophone.cpp

示例5: ccTouchesEnded

void TestController::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
    CCAction* delaytime = CCActionManager::sharedManager()->getActionByTag(99,this);
    if(delaytime != NULL)
        if(delaytime->isDone() == false)
        {
            CCSetIterator it = pTouches->begin();
            CCTouch* touch = (CCTouch*)(*it);
            CCPoint p1 =	m_tBeginPos;
            CCPoint p2 =	touch->locationInView(touch->view());
            float x = m_pItmeMenu->getPosition().x + (p2.x - p1.x) * 5;
            if(x>= 0)
                x = 0;
            else if(x <= -m_pItmeMenu->getContentSize().width)
                x = -m_pItmeMenu->getContentSize().width;
            CCMoveTo* move = CCMoveTo::actionWithDuration(1,CCPointMake(x,0));
            CCActionInterval* ease = CCEaseOut::actionWithAction(move,3.0);
            m_pItmeMenu->runAction(ease);
        }
}
开发者ID:Openxlive,项目名称:cocos2d-x-win8-tests-metro-style,代码行数:20,代码来源:controller.cpp

示例6: onTouchesEnded

void Clayer_ripple_horizontal::onTouchesEnded(const std::vector<Touch*>& touches, Event *unused_event)
{
    //Add a new body/atlas sprite at the touched location
     
    CCTouch* touch;
    
    for(auto  it = touches.begin(); it != touches.end(); it++)
    {
        touch = (CCTouch*)(*it);
        
        if(!touch)
            break;
        
        CCPoint location = touch->getLocationInView();
        
        location = CCDirector::sharedDirector()->convertToGL(location);
        //    cout<<"mos pos:"<<location.x<<" "<<location.y<<endl;
        break;
    }
}
开发者ID:propros,项目名称:effectnode,代码行数:20,代码来源:layer_ripple_horizontal.cpp

示例7: ccTouchesEnded

void CtestLayer::ccTouchesEnded(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();
        
        //----update mos
        m_mosPosf=m_mosPos;
        m_mosPos=pointInWinSpace;
        
    }
}
开发者ID:liqt,项目名称:3DToolKit-2-for-cocos2dx,代码行数:20,代码来源:testLayer.cpp

示例8: ccTouchesBegan

void HelloWorld::ccTouchesBegan(CCSet *touches,CCEvent *event){
	
if (_mouseJoint!=NULL) return;

CCTouch *myTouch =(CCTouch*) touches->anyObject();
CCPoint location = myTouch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);

if (resinBallBody->_ballBody->GetFixtureList()->TestPoint(locationWorld)) {
b2MouseJointDef md;
md.bodyA = _groundBody;
md.bodyB =resinBallBody->_ballBody;
md.target =resinBallBody->_ballBody->GetWorldCenter();
md.collideConnected =true;
md.maxForce =1000.0f* resinBallBody->_ballBody->GetMass();
_mouseJoint = (b2MouseJoint *)_world->CreateJoint(&md);
resinBallBody->_ballBody->SetAwake(true);
}
}
开发者ID:yangyujiang,项目名称:Box2DTest2,代码行数:20,代码来源:HelloWorldScene.cpp

示例9: ccTouchesEnded

void SceneNode::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
    touchValid=false;
    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);
	
    }
}
开发者ID:prsimpson,项目名称:ripple-gpu,代码行数:20,代码来源:SceneNode.cpp

示例10: ccTouchesEnded

void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
    //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);
        
        addNewSpriteAtPosition( location );
    }
}
开发者ID:cocoaheadskaohsiung,项目名称:cocos2dx-hybrid-project,代码行数:20,代码来源:HelloWorldScene.cpp

示例11: ccTouchesEnded

void Clayer_ripple_horizontal::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
    //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);
        //    cout<<"mos pos:"<<location.x<<" "<<location.y<<endl;
        break;
    }
}
开发者ID:yhz61010,项目名称:EffectNodes-for-cocos2dx,代码行数:20,代码来源:layer_ripple_horizontal.cpp

示例12: ccTouchesBegan

void GamePlay::ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event) {
	CCTouch* touch = (CCTouch*)(touches->anyObject());
	CCPoint location = touch->getLocationInView();
	location = CCDirector::sharedDirector()->convertToGL(location);

	int width = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().width;
	if(location.x < width/2) {
		// move left
		int x = mUserCar->getPositionX() - width/mNumLane;
		if(x > mUserCar->getContentSize().width /2) {
			mUserCar->setPositionX(x);
		}
	} else {
		// move right
		int x = mUserCar->getPositionX() + width/mNumLane;
		if(x < width - mUserCar->getContentSize().width /2) {
			mUserCar->setPositionX(x);
		}
	}
}
开发者ID:nvhausid,项目名称:MiniRacing,代码行数:20,代码来源:GamePlay.cpp

示例13:

void Box2DTestLayer::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
	//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->locationInView(touch->view());
		
		location = CCDirector::sharedDirector()->convertToGL(location);
	
		addNewSpriteWithCoords( location );
	}
}
开发者ID:BigHand,项目名称:cocos2d-x,代码行数:20,代码来源:Box2dTest.cpp

示例14: ccTouchesBegan

void GameLayer::ccTouchesBegan(CCSet* pTouches, CCEvent* pEvent)
{
    for (CCSetIterator iter = pTouches->begin(); iter != pTouches->end(); ++ iter)
    {
        CCTouch* pTouch = (CCTouch*)(*iter);
        if (pTouch)
        {
            CCPoint tap = pTouch->getLocation();
            for (int p = 0; p < 2; ++ p)
            {
                GameSprite* pGS = (GameSprite*)m_pArrPlayers->objectAtIndex(p);
                
                if (pGS->boundingBox().containsPoint(tap))
                {
                    pGS->setTouch(pTouch);
                }
            }
        }
    }
}
开发者ID:ivanchenhz,项目名称:IvanChenGit,代码行数:20,代码来源:GameLayer.cpp

示例15: ccTouchesBegan

void GameState::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
	CCTouch* touch = (CCTouch*)( pTouches->anyObject() );
	CCPoint location = touch->getLocation();

	touchPoint = location;
	pressing = true;

	if(stageManager->getPlayer()->weaponManager->containPointWithReloadSpr(touchPoint))
	{
		isPressReload = true;
		SoundManager::getInstance()->playEffect("music/ui/ui_reload.ogg");
		stageManager->getPlayer()->weaponManager->pressingReloadSpr();
	}
	if(tutorialManager->getCurrentPage() == 5)
	{
		this->resumeSchedulerAndActions();
		tutorialManager->increasePage();
	}
}
开发者ID:CicadaKim,项目名称:ZombieHunter,代码行数:20,代码来源:GameState.cpp


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