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