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


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

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


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

示例1: ccTouchesMoved

void RoleLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) {
	for (CCSetIterator it = pTouches->begin(); it != pTouches->end(); it++) {
		CCTouch *touch = (CCTouch *)*it;
		int id = touch->getID();
		CCString * id_str = CCString::createWithFormat("moved: %d",id);
		((CCLabelTTF *)this->getChildByTag(kDebugLabel))->setString(id_str->getCString());
		CCLOGINFO("%s", id_str->getCString());
	}
}
开发者ID:wang-yichun,项目名称:Gravity,代码行数:9,代码来源:RoleLayer.cpp

示例2: ccTouchesBegan

void MutiTouchTestLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
    CCSetIterator iter = pTouches->begin();
    for (; iter != pTouches->end(); iter++)
    {
        CCTouch* pTouch = (CCTouch*)(*iter);
        TouchPoint* pTouchPoint = TouchPoint::touchPointWithParent(this);
        CCPoint location = pTouch->locationInView();
        location = CCDirector::sharedDirector()->convertToGL(location);

        pTouchPoint->setTouchPos(location);
        pTouchPoint->setTouchColor(s_TouchColors[pTouch->getID()]);

        addChild(pTouchPoint);
        s_dic.setObject(pTouchPoint, pTouch->getID());
    }
    

}
开发者ID:csdnnet,项目名称:hiygame,代码行数:19,代码来源:MutiTouchTest.cpp

示例3:

CCTouch *CCTouchTargetNode::findTouchFromTouchesSet(CCSet *touches, int touchId)
{
    CCTouch *touch = NULL;
    for (CCSetIterator it = touches->begin(); it != touches->end(); ++it)
    {
        touch = (CCTouch*)*it;
        if (touch->getID() == touchId) return touch;
    }
    return NULL;
}
开发者ID:Pythoner-xu,项目名称:quick-cocos2d-x,代码行数:10,代码来源:CCScene.cpp

示例4: ccTouchesMoved

KDvoid TestMultiTouch::ccTouchesMoved ( CCSet* pTouches, CCEvent* pEvent )
{
	for ( CCSetIterator  iter = pTouches->begin ( ); iter != pTouches->end ( ); iter++ )
	{
        CCTouch*     pTouch = (CCTouch*) ( *iter );
        TouchPoint*  pTouchPoint = (TouchPoint*) m_tDictionary.objectForKey ( pTouch->getID ( ) );

        pTouchPoint->setTouchPos ( this->convertTouchToNodeSpace ( pTouch ) );
	}
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:10,代码来源:TestMultiTouch.cpp

示例5: ccTouchesMoved

KDvoid TestBlade::ccTouchesMoved ( CCSet* pTouches, CCEvent* pEvent )
{
	for ( CCSetIterator it = pTouches->begin ( ); it != pTouches->end ( ); it++ ) 
	{
		CCTouch*		pTouch	  = (CCTouch*) ( *it );
		CCPoint			tLocation = this->convertTouchToNodeSpace ( pTouch );
		
		CCBlade*		pBlade	  = (CCBlade*) m_pDictionary->objectForKey ( pTouch->getID ( ) );
		pBlade->push ( tLocation );
	}
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:11,代码来源:TestBlade.cpp

示例6: ccTouchesMoved

void MutiTouchTestLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
    CCSetIterator iter = pTouches->begin();
    for (; iter != pTouches->end(); iter++)
    {
        CCTouch* pTouch = (CCTouch*)(*iter);
        TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID());
        CCPoint location = pTouch->getLocation();
        pTP->setTouchPos(location);
    }
}
开发者ID:GhostSoar,项目名称:Cocos2dWindows,代码行数:11,代码来源:MutiTouchTest.cpp

示例7: ccTouchesMoved

void MutiTouchTestLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
    CCSetIterator iter = pTouches->begin();
    for (; iter != pTouches->end(); iter++)
    {
        CCTouch* pTouch = (CCTouch*)(*iter);
        TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID());
        CCPoint location = pTouch->locationInView();
        location = CCDirector::sharedDirector()->convertToGL(location);
        pTP->setTouchPos(location);
    }
}
开发者ID:csdnnet,项目名称:hiygame,代码行数:12,代码来源:MutiTouchTest.cpp

示例8: checkForSelection

void SelectionRecognizer::checkForSelection(CCObject* obj)
{
    CCTouch* touch = (CCTouch*)obj;
    //the touch could have been discarded in the meantime
    if(isTouchInSelection(touch))
    {
        CCPoint currentLocation = Scene::touchPosition(touch);
        CCPoint touchOrigin = TOPOINT(storedTouches->objectForKey(touch->getID()));
        CCObject* target = mainLinker->linkedObjectOf(touch);
        if(ccpDistance(Scene::touchPosition(touch), touchOrigin) <= maxMovement)
        {
            CCNotificationCenter::sharedNotificationCenter()->postNotification("SelectionRecognized", DcreateP(touch, Screate("Touch"), target, Screate("Target"), NULL));
        }
        else
        {
            CCNotificationCenter::sharedNotificationCenter()->postNotification("SelectionCanceled", DcreateP(touch, Screate("Touch"), storedTouches->objectForKey(touch->getID()), Screate("Origin"), target, Screate("Target"), NULL));
        }
        
        storedTouches->removeObjectForKey(touch->getID());
    }
}
开发者ID:nikhildhamsaniya,项目名称:FenneX,代码行数:21,代码来源:SelectionRecognizer.cpp

示例9: ccTouchesMoved

void BaseContentWrapLayer::ccTouchesMoved (CCSet *pTouches, CCEvent *pEvent)
{
	if (!mBaseScene->getCollisionEnable())
	{
		return;
	}

	if (mFixedScaling)
	{
		return;
	}
	
	CCTouch* touch = (CCTouch*)(*(pTouches->begin()));
    if(touch->getID() != 0 || pTouches->count() > 1)
        return;
    
	CCPoint currentPos = touch->getLocation();
	mVCalculate->addTouchMoveRecord(currentPos);

	float x_offset = currentPos.x - mLastTouchPos.x;
	float y_offset = currentPos.y - mLastTouchPos.y;

	setPositionX(getPositionX() + x_offset);
	setPositionY(getPositionY() + y_offset);

	mLastTouchPos = currentPos;

	float min_x;
	float min_y;
	float max_x;
	float max_y;
	getBoarderPos(min_x,min_y,max_x,max_y);

	if (getPositionX() < min_x)
	{
		setPositionX(min_x);
	}
	if (getPositionX() > max_x)
	{
		setPositionX(max_x);
	}

	if (getPositionY() < min_y)
	{
		setPositionY(min_y);
	}
	if (getPositionY() > max_y)
	{
		setPositionY(max_y);
	}
	

}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:53,代码来源:BaseContentWrapLayer.cpp

示例10: ccTouchesBegan

void EXZoomController::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent){
    
    CCSetIterator iter = pTouches->begin();
    for (; iter != pTouches->end(); iter++){
        CCTouch* pTouch = (CCTouch*)(*iter);
        //        CCPoint location = pTouch->getLocation();
        _touchesDic->setObject(pTouch, CCString::createWithFormat("%d",pTouch->getID())->getCString());
        CCLog("touc id %s,",CCString::createWithFormat("%d",pTouch->getID())->getCString());
    }
	
	bool multitouch = _touchesDic->count() > 1;
	
	if (multitouch){
        //reset history so auto scroll doesn't happen
        _timePointStampCounter = 0;
        
		endScroll(_firstTouch);
        
        CCArray* keys = _touchesDic->allKeys();
        CCTouch *touch1 = (CCTouch*)_touchesDic->objectForKey(((CCString*)keys->objectAtIndex(0))->getCString());
		CCTouch *touch2 = (CCTouch*)_touchesDic->objectForKey(((CCString*)keys->objectAtIndex(1))->getCString());
        
		CCPoint pt = touch1->getLocationInView();
		CCPoint pt2 = touch2->getLocationInView();
        
		beginZoom(pt, pt2);
	} else {
        //record the point for determining velocity
        CCArray* keys = _touchesDic->allKeys();
        //        ((CCString*)keys->objectAtIndex(0))->getCString()
        
        _touchesDic->objectForKey(((CCString*)keys->objectAtIndex(0))->getCString());
        
        CCTouch *touch = (CCTouch*)_touchesDic->objectForKey(((CCString*)keys->objectAtIndex(0))->getCString());
        recordScrollPoint(touch);
		beginScroll(_node->convertToNodeSpace(touch->getLocation()));
    }
	
}
开发者ID:aquariusgx,项目名称:coc,代码行数:39,代码来源:EXZoomController.cpp

示例11: ccTouchesBegan

void BaseContentWrapLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
	if (!mBaseScene->getCollisionEnable())
	{
		return;
	}

	CCTouch* touch = (CCTouch*)(*(pTouches->begin()));
    if(touch->getID() != 0 || pTouches->count() > 1)
        return;
    
	mScrollControler->stopScrolling();
	mVCalculate->clearRecord();
	mLastTouchPos = touch->getLocation();
}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:15,代码来源:BaseContentWrapLayer.cpp

示例12: executeLayerTouchesEvent

int CCLuaEngine::executeLayerTouchesEvent(CCLayer* pLayer, int eventType, CCSet *pTouches)
{
    CCTouchScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptTouchHandlerEntry();
    if (!pScriptHandlerEntry) return 0;
    int nHandler = pScriptHandlerEntry->getHandler();
    if (!nHandler) return 0;
    
    switch (eventType)
    {
        case CCTOUCHBEGAN:
            m_stack->pushString("began");
            break;
            
        case CCTOUCHMOVED:
            m_stack->pushString("moved");
            break;
            
        case CCTOUCHENDED:
            m_stack->pushString("ended");
            break;
            
        case CCTOUCHCANCELLED:
            m_stack->pushString("cancelled");
            break;
            
        default:
            return 0;
    }

    CCDirector* pDirector = CCDirector::sharedDirector();
    lua_State *L = m_stack->getLuaState();
    lua_newtable(L);
    int i = 1;
    for (CCSetIterator it = pTouches->begin(); it != pTouches->end(); ++it)
    {
        CCTouch* pTouch = (CCTouch*)*it;
        CCPoint pt = pDirector->convertToGL(pTouch->getLocationInView());
        lua_pushnumber(L, pt.x);
        lua_rawseti(L, -2, i++);
        lua_pushnumber(L, pt.y);
        lua_rawseti(L, -2, i++);
        lua_pushinteger(L, pTouch->getID());
        lua_rawseti(L, -2, i++);
    }
    int ret = m_stack->executeFunctionByHandler(nHandler, 2);
    m_stack->clean();
    return ret;
}
开发者ID:2193q,项目名称:cocos2d-x,代码行数:48,代码来源:CCLuaEngine.cpp

示例13: ccTouchesBegan

KDvoid TestBlade::ccTouchesBegan ( CCSet* pTouches, CCEvent* pEvent )
{
	for ( CCSetIterator it = pTouches->begin ( ); it != pTouches->end ( ); it++ ) 
	{
		CCTouch*		pTouch	  = (CCTouch*) ( *it );
		CCPoint			tLocation = this->convertTouchToNodeSpace ( pTouch );
		
		CCBlade*		pBlade	  = CCBlade::create ( 50 );
		pBlade->setAutoDim ( KD_TRUE );

		KDint			nRand	  = kdRand ( ) % 3 + 1;
		CCTexture2D*	pTexture  = CCTextureCache::sharedTextureCache ( )->addImage ( ccszf ( "xm_supports/streak%d-hd.png", nRand ) );
		pBlade->setTexture ( pTexture );
		pBlade->push ( tLocation );

		this->addChild ( pBlade );	

		m_pDictionary->setObject ( pBlade, pTouch->getID ( ) );
	}
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:20,代码来源:TestBlade.cpp

示例14: ccTouchesEnded

void BaseContentWrapLayer::ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event)
{

	if (!mBaseScene->getCollisionEnable())
	{
		return;
	}

	CCTouch* touch = (CCTouch*)(*(touches->begin()));
    if(touch->getID() != 0 || touches->count() > 1)
        return;
    
	if (mFixedScaling)
		return;


	ScrollConfig config;
	config.decelerate = 0.95f;
	getBoarderPos(config.minPosX,config.minPosY,config.maxPosX,config.maxPosY);
	config.scrollSpeed = mVCalculate->getCurrentInstantaneousSpeed();
	config.toScroll = this;
	mScrollControler->scrollWithNoRebound(config);
}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:23,代码来源:BaseContentWrapLayer.cpp

示例15: ccTouchesEnded

void EXZoomController::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent){
    bool multitouch = _touchesDic->count() > 1;
	if (multitouch) {
        CCArray* keys = _touchesDic->allKeys();
        CCTouch *touch1 = (CCTouch*)_touchesDic->objectForKey(((CCString*)keys->objectAtIndex(0))->getCString());
		CCTouch *touch2 = (CCTouch*)_touchesDic->objectForKey(((CCString*)keys->objectAtIndex(1))->getCString());
        
		CCPoint pt1 = touch1->getLocationInView();
		CCPoint pt2 = touch2->getLocationInView();
		
		endZoom(pt1, pt2);
		
		//which touch remains?
        //		if (touch == touch2)
        //			beginScroll(_node->convertToNodeSpace(touch1->getLocation()));
        //		else
        beginScroll(_node->convertToNodeSpace(touch2->getLocation()));
	} else {
        CCArray* keys = _touchesDic->allKeys();
        CCTouch *touch = (CCTouch*)_touchesDic->objectForKey(((CCString*)keys->objectAtIndex(0))->getCString());
        recordScrollPoint(touch);
		
        CCPoint pt = _node->convertToNodeSpace(touch->getLocation());
		endScroll(pt);
        
        //handle double-tap zooming
        //        if (zoomOnDoubleTap /**&& [touch tapCount] == 2*/)
        //            handleDoubleTapAt(pt);
	}
	
    CCSetIterator iter = pTouches->begin();
    for (; iter != pTouches->end(); iter++){
        CCTouch* pTouch = (CCTouch*)(*iter);
        _touchesDic->removeObjectForKey(CCString::createWithFormat("%d",pTouch->getID())->getCString());
    }
}
开发者ID:aquariusgx,项目名称:coc,代码行数:36,代码来源:EXZoomController.cpp


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