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


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

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


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

示例1: onTouchesCancelled

void CWidgetWindow::onTouchesCancelled(const std::vector<Touch*>&touches, Event *unused_event)
{
	for(unsigned int i=0;i<touches.size(); i++)
	{
		Touch* pTouch = touches.at(i);
		map<int, __ccMULTITOUCHTARGET>::iterator mitr = m_mMultiTouchKeeper.find(pTouch->getID());
		if( mitr != m_mMultiTouchKeeper.end() )
		{
			if( mitr->second.pWidget )
			{
				if( mitr->second.pWidget->isTouchInterrupted() )
				{
					if( mitr->second.pLongClickedWidgetObject )
					{
						executeTouchCancelledAfterLongClickHandler(mitr->second.pLongClickedWidgetObject, pTouch, mitr->second.fTouchedDuration);
					}
				}
				else
				{
					mitr->second.pWidget->interruptTouchCascade(pTouch, mitr->second.fTouchedDuration);
				}
			}
			m_mMultiTouchKeeper.erase(mitr);
		}
	}
}
开发者ID:110440,项目名称:Tui-x,代码行数:26,代码来源:WidgetWindow.cpp

示例2: handleTouchesEvent

int LuaEngine::handleTouchesEvent(void* data)
{
    if (NULL == data)
        return 0;

    TouchesScriptData* touchesScriptData = static_cast<TouchesScriptData*>(data);
    if (NULL == touchesScriptData->nativeObject || NULL == touchesScriptData->touches)
        return 0;

    int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)touchesScriptData->nativeObject, ScriptHandlerMgr::kTouchesHandler);

    if (0 == handler)
        return 0;

    switch (touchesScriptData->actionType)
    {
    case CCTOUCHBEGAN:
        _stack->pushString("began");
        break;

    case CCTOUCHMOVED:
        _stack->pushString("moved");
        break;

    case CCTOUCHENDED:
        _stack->pushString("ended");
        break;

    case CCTOUCHCANCELLED:
        _stack->pushString("cancelled");
        break;

    default:
        return 0;
    }

    Director* pDirector = Director::getInstance();
    lua_State *L = _stack->getLuaState();
    int ret = 0;

    lua_newtable(L);
    int i = 1;
    for (SetIterator it = touchesScriptData->touches->begin(); it != touchesScriptData->touches->end(); ++it)
    {
        Touch* pTouch = static_cast<Touch*>(*it);
        Point 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++);
    }
    ret = _stack->executeFunctionByHandler(handler, 2);

    _stack->clean();
    return ret;
}
开发者ID:CBanDa,项目名称:cocos2d-x-3.0alpha0-pre,代码行数:58,代码来源:CCLuaEngine.cpp

示例3: onTouchesBegan

void CWidgetWindow::onTouchesBegan(const std::vector<Touch*>&touches, Event *unused_event)
{
	for(unsigned int i=0;i<touches.size(); i++)
	{
		Touch* pTouch = touches.at(i);
		if( m_bTouchEnabled && m_bMultiTouchEnabled && _visible &&  _children.size() > 0 )
		{
			Vec2 touchPointInView = convertToNodeSpace(pTouch->getLocation());

				for(int j=_children.size()-1;j>=0;--j){
					Node* pNode = _children.at(j);
					CWidget* pWidget = dynamic_cast<CWidget*>(pNode);
					if( pWidget && pNode->isVisible() && pWidget->isEnabled() && pWidget->isTouchEnabled() )
					{
						bool bSameWidgetBreak = false;
						if( pNode->getBoundingBox().containsPoint(touchPointInView) )
						{
							//make sure it can not happened on the same widget
							map<int, __ccMULTITOUCHTARGET>::iterator mitr = m_mMultiTouchKeeper.begin();
							for(; mitr != m_mMultiTouchKeeper.end(); ++mitr)
							{
								if( mitr->second.pWidget == pWidget )
								{
									bSameWidgetBreak = true;
									break;
								}
							}

							if( bSameWidgetBreak )
							{
								break;
							}

							if( pWidget->executeTouchBeganHandler(pTouch) != eWidgetTouchNone )
							{
								__ccMULTITOUCHTARGET tKeeper;
								tKeeper.fTouchedDuration = 0.000001f;
								tKeeper.pWidget = pWidget;
								tKeeper.pLongClickedWidgetObject = NULL;
								m_mMultiTouchKeeper[pTouch->getID()] = tKeeper;
								return;
							}
						}
					}
				
			}

		}
	}
}
开发者ID:110440,项目名称:Tui-x,代码行数:50,代码来源:WidgetWindow.cpp

示例4: executeLayerTouchesEvent

int LuaEngine::executeLayerTouchesEvent(Layer* pLayer, int eventType, Set *pTouches)
{
    TouchScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptTouchHandlerEntry();
    if (!pScriptHandlerEntry) return 0;
    int nHandler = pScriptHandlerEntry->getHandler();
    if (!nHandler) return 0;
    
    switch (eventType)
    {
        case CCTOUCHBEGAN:
            _stack->pushString("began");
            break;
            
        case CCTOUCHMOVED:
            _stack->pushString("moved");
            break;
            
        case CCTOUCHENDED:
            _stack->pushString("ended");
            break;
            
        case CCTOUCHCANCELLED:
            _stack->pushString("cancelled");
            break;
            
        default:
            return 0;
    }

    Director* pDirector = Director::sharedDirector();
    lua_State *L = _stack->getLuaState();
    lua_newtable(L);
    int i = 1;
    for (SetIterator it = pTouches->begin(); it != pTouches->end(); ++it)
    {
        Touch* pTouch = (Touch*)*it;
        Point 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 = _stack->executeFunctionByHandler(nHandler, 2);
    _stack->clean();
    return ret;
}
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:48,代码来源:CCLuaEngine.cpp

示例5: onTouchEnded

void UINumberPicker::onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *unused_event)
{
    do
    {
        CC_BREAK_IF(!isVisible());
        
        if (containsTouchObject(m_pTouches, touch))
        {
            if (m_pTouches.size() == 1 && m_bTouchMoved)
            {
                //手指放开,自由移动
                schedule(schedule_selector(UINumberPicker::deaccelerateScrolling));
            }
            if (m_pTouches.size() == 1 && !m_bTouchMoved)
            {
                //判断当前时一个单击行为,获取当前点击的是哪一个Item;
                PickerCell *cell = itemForPoint(m_tTouchPoint);
                setSelectedItem(cell);
            }
            std::vector<Touch*>::iterator ite = m_pTouches.begin();
            while (ite != m_pTouches.end())
            {
                Touch *ptouch =*ite;
                if (ptouch->getID() == touch->getID())
                {
                    m_pTouches.erase(ite);
                    break;
                }
                ite++;
            }
        }
        if (m_pTouches.size() == 0)
        {
            m_bDragging = false;
            m_bTouchMoved = false;
        }
        m_bIsScrolling = true;
    }
    while (0);
}
开发者ID:haroel,项目名称:CocosTestCollection,代码行数:40,代码来源:UINumberPicker.cpp

示例6: executeNodeTouchesEvent

int LuaEngine::executeNodeTouchesEvent(Node* pNode, int eventType, const std::vector<Touch*>& touches, int phase)
{
    CCScriptEventListenersForEvent *listeners = getListeners(pNode, phase == NODE_TOUCH_CAPTURING_PHASE ? NODE_TOUCH_CAPTURE_EVENT : NODE_TOUCH_EVENT);
    if (!listeners) return 1;
    
    _stack->clean();
    LuaValueDict event;
    switch (eventType)
    {
        case CCTOUCHBEGAN:
            event["name"] = LuaValue::stringValue("began");
            break;
            
        case CCTOUCHMOVED:
            event["name"] = LuaValue::stringValue("moved");
            break;
            
        case CCTOUCHENDED:
            event["name"] = LuaValue::stringValue("ended");
            break;
            
        case CCTOUCHCANCELLED:
            event["name"] = LuaValue::stringValue("cancelled");
            break;
            
        case CCTOUCHADDED:
            event["name"] = LuaValue::stringValue("added");
            break;
            
        case CCTOUCHREMOVED:
            event["name"] = LuaValue::stringValue("removed");
            break;
            
        default:
            return 0;
    }
    
    event["mode"] = LuaValue::intValue((int)Touch::DispatchMode::ALL_AT_ONCE);
    switch (phase)
    {
        case NODE_TOUCH_CAPTURING_PHASE:
            event["phase"] = LuaValue::stringValue("capturing");
            break;
            
        case NODE_TOUCH_TARGETING_PHASE:
            event["phase"] = LuaValue::stringValue("targeting");
            break;
            
        default:
            event["phase"] = LuaValue::stringValue("unknown");
    }
    
    LuaValueDict points;
    Director* pDirector = Director::getInstance();
    char touchId[16];
    for (auto touchIt = touches.begin(); touchIt != touches.end(); ++touchIt)
    {
        LuaValueDict point;
        Touch* pTouch = (Touch*)*touchIt;
        sprintf(touchId, "%d", pTouch->getID());
        point["id"] = LuaValue::stringValue(touchId);
        
        const Point pt = pDirector->convertToGL(pTouch->getLocationInView());
        point["x"] = LuaValue::floatValue(pt.x);
        point["y"] = LuaValue::floatValue(pt.y);
        const Point prev = pDirector->convertToGL(pTouch->getPreviousLocationInView());
        point["prevX"] = LuaValue::floatValue(prev.x);
        point["prevY"] = LuaValue::floatValue(prev.y);
        
        points[touchId] = LuaValue::dictValue(point);
    }
    event["points"] = LuaValue::dictValue(points);
    _stack->pushLuaValueDict(event);
    
    bool flagNeedClean = false;
    for (auto it=listeners->begin(); it!=listeners->end(); ++it)
    {
        if ((*it)->removed) {
            flagNeedClean = true;
            continue;
        }
        
        _stack->copyValue(1);
        _stack->executeFunctionByHandler((*it)->listener, 1);
        _stack->settop(1);
    }
    
    cleanListeners(listeners, pNode, flagNeedClean);
    
    _stack->clean();
    
    return 1;
}
开发者ID:bodogbo,项目名称:v3quick-classic,代码行数:93,代码来源:CCLuaEngine.cpp

示例7: dispatchingTouchEventReal

void LuaTouchEventManager::dispatchingTouchEventReal(const std::vector<Touch*>& touches, Event *pEvent, int event)
{
    LuaEventNode *node = nullptr;
    LuaTouchTargetNode *touchTarget = nullptr;
    Touch *touch = nullptr;

    ssize_t count = _touchingTargets.size();
    //CCLOG("dispatchingTouchEvent COUNT [%zd]", count);
    for (ssize_t i = 0; i < count; ++i)
    {
        touchTarget = _touchingTargets.at(i);

        if (!touchTarget->getNode()->isRunning())
        {
            // target removed from scene, remove it
            //            CCLOG("REMOVE TARGET [%u]", i);
            _touchingTargets.erase(i);
            --count;
            --i;
            continue;
        }

        int touchMode = touchTarget->getTouchMode();
        if (touchMode != LuaEventNode::modeTouchesAllAtOnce)
        {
            touch = touchTarget->findTouch(touches);
            if (!touch)
            {
                // not found touch id for target, skip this target
                continue;
            }
        }

        // try to dispatching event
        Vector<LuaEventNode*> path(10);
        node = touchTarget->getNode();
        do
        {
            path.pushBack(node);
            node = node->getParent();
        } while (node != nullptr /*&& node != this*/);

        // phase: capturing
        // from parent to child
        for (long j = path.size() - 1; j >= 0; --j)
        {
            node = path.at(j);
            if (touchMode == LuaEventNode::modeTouchesAllAtOnce)
            {
                switch (event)
                {
                case CCTOUCHMOVED:
                    node->ccTouchesCaptureMoved(touches, touchTarget->getNode());
                    break;

                case CCTOUCHENDED:
                    node->ccTouchesCaptureEnded(touches, touchTarget->getNode());
                    break;

                case CCTOUCHCANCELLED:
                    node->ccTouchesCaptureCancelled(touches, touchTarget->getNode());
                    break;

                case CCTOUCHADDED:
                    node->ccTouchesCaptureAdded(touches, touchTarget->getNode());
                    break;

                case CCTOUCHREMOVED:
                    node->ccTouchesCaptureRemoved(touches, touchTarget->getNode());
                    break;
                }
            }
            else
            {
                switch (event)
                {
                case CCTOUCHMOVED:
                    node->ccTouchCaptureMoved(touch, touchTarget->getNode());
                    break;

                case CCTOUCHENDED:
                    node->ccTouchCaptureEnded(touch, touchTarget->getNode());
                    break;

                case CCTOUCHCANCELLED:
                    node->ccTouchCaptureCancelled(touch, touchTarget->getNode());
                    break;

                case CCTOUCHREMOVED:
                    if (touch->getID() == touchTarget->getTouchId())
                    {
                        node->ccTouchCaptureEnded(touch, touchTarget->getNode());
                    }
                    break;
                }
            }
        } // for (long j = path.size() - 1; j >= 0; --j)

        // phase: targeting
        node = touchTarget->getNode();
//.........这里部分代码省略.........
开发者ID:CheukKin,项目名称:HelloWorld,代码行数:101,代码来源:LuaTouchEventManager.cpp

示例8: onTouchesBegan

void LuaTouchEventManager::onTouchesBegan(const std::vector<Touch*>& touches, Event *event)
{
    if (!m_touchDispatchingEnabled || _touchableNodes.size() < 1) return;

    // save touches id
    for (auto it = touches.begin(); it != touches.end(); ++it)
    {
        m_touchingIds.insert(((Touch*)*it)->getID());
    }

    // check current in touching
    if (_touchingTargets.size())
    {
        dispatchingTouchEvent(touches, event, CCTOUCHADDED);
        return;
    }

    // start new touching event
    // sort touchable nodes
    sortAllTouchableNodes(_touchableNodes);

    // find touching target
    bool isTouchable = true;
    LuaEventNode *node = nullptr;
    LuaEventNode *checkTouchableNode = nullptr;
    LuaTouchTargetNode *touchTarget = nullptr;

    for (auto iter = _touchableNodes.begin(); iter != _touchableNodes.end(); ++iter)
    {
        checkTouchableNode = node = *iter;

        // check node is visible and capturing enabled
        isTouchable = true;
        do
        {
            isTouchable = isTouchable
                          && checkTouchableNode->isRunning()
                          && checkTouchableNode->isVisible()
                          && checkTouchableNode->isTouchCaptureEnabled();
            checkTouchableNode = checkTouchableNode->getParent();
        } while (checkTouchableNode && isTouchable);
        if (!isTouchable) continue;

        // prepare for touch testing
        touchTarget = nullptr;
        Node *activeNode = node->getActiveNode();
        if (!activeNode) continue;
        const Rect boundingBox = utils::getCascadeBoundingBox(activeNode);

        // set touch target
        Touch *touch = nullptr;
        for (auto it = touches.begin(); it != touches.end(); ++it)
        {
            touch = (Touch*)*it;
            const Point touchPoint = touch->getLocation();

            if (boundingBox.containsPoint(touchPoint))
            {
                if (!touchTarget)
                {
                    touchTarget = LuaTouchTargetNode::create(node);
                }

                if (touchTarget->getTouchMode() == LuaEventNode::modeTouchesOneByOne)
                {
                    touchTarget->setTouchId(touch->getID());
                    break;
                }
            }
        }

        if (!touchTarget)
        {
            // touch points not in current target, try to next
            continue;
        }

        // try to dispatching event
        Vector<LuaEventNode*> path(10);
        node = touchTarget->getNode();
        do
        {
            path.pushBack(node);
            node = node->getParent();
        } while (node != nullptr /*&& node != this*/);

        // phase: capturing
        // from parent to child
        bool dispatchingContinue = true;
        int touchMode = touchTarget->getTouchMode();
        for (long i = path.size() - 1; dispatchingContinue && i >= 0; --i)
        {
            node = path.at(i);
            if (touchMode == LuaEventNode::modeTouchesAllAtOnce)
            {
                node->ccTouchesCaptureBegan(touches, touchTarget->getNode());
            }
            else
            {
                dispatchingContinue = node->ccTouchCaptureBegan(touchTarget->findTouch(touches), touchTarget->getNode());
//.........这里部分代码省略.........
开发者ID:CheukKin,项目名称:HelloWorld,代码行数:101,代码来源:LuaTouchEventManager.cpp

示例9: executeScriptTouchHandler

int LuaEventNode::executeScriptTouchHandler(int nEventType, const std::vector<Touch*>& touches, int phase /* = NODE_TOUCH_TARGETING_PHASE */)
{
    auto stack = initExecParam(this->getActiveNode(), phase);
    if (!stack)
    {
        return 0;
    }
    
    LuaValueDict event;
    switch (nEventType)
    {
        case CCTOUCHBEGAN:
            event["name"] = LuaValue::stringValue("began");
            break;
            
        case CCTOUCHMOVED:
            event["name"] = LuaValue::stringValue("moved");
            break;
            
        case CCTOUCHENDED:
            event["name"] = LuaValue::stringValue("ended");
            break;
            
        case CCTOUCHCANCELLED:
            event["name"] = LuaValue::stringValue("cancelled");
            break;
            
        case CCTOUCHADDED:
            event["name"] = LuaValue::stringValue("added");
            break;
            
        case CCTOUCHREMOVED:
            event["name"] = LuaValue::stringValue("removed");
            break;
            
        default:
            return 0;
    }
    
    event["mode"] = LuaValue::intValue((int)Touch::DispatchMode::ALL_AT_ONCE);
    switch (phase)
    {
        case NODE_TOUCH_CAPTURING_PHASE:
            event["phase"] = LuaValue::stringValue("capturing");
            break;
            
        case NODE_TOUCH_TARGETING_PHASE:
            event["phase"] = LuaValue::stringValue("targeting");
            break;
            
        default:
            event["phase"] = LuaValue::stringValue("unknown");
    }
    
    LuaValueDict points;
    Director* pDirector = Director::getInstance();
    char touchId[16];
    for (auto touchIt = touches.begin(); touchIt != touches.end(); ++touchIt)
    {
        LuaValueDict point;
        Touch* pTouch = (Touch*)*touchIt;
        sprintf(touchId, "%d", pTouch->getID());
        point["id"] = LuaValue::stringValue(touchId);
        
        const Point pt = pDirector->convertToGL(pTouch->getLocationInView());
        point["x"] = LuaValue::floatValue(pt.x);
        point["y"] = LuaValue::floatValue(pt.y);
        const Point prev = pDirector->convertToGL(pTouch->getPreviousLocationInView());
        point["prevX"] = LuaValue::floatValue(prev.x);
        point["prevY"] = LuaValue::floatValue(prev.y);
        
        points[touchId] = LuaValue::dictValue(point);
    }
    event["points"] = LuaValue::dictValue(points);

    return callNodeEventDispatcher(stack, event);
}
开发者ID:SunLightJuly,项目名称:Quick-PrebuiltRuntimeLua,代码行数:77,代码来源:LuaEventNode.cpp

示例10: onTouchesBegan

void Viewport::onTouchesBegan(const std::vector<Touch*>& pTouches, Event *pEvent)
{
    unscheduleAll();
    CC_ASSERT(this->m_TargetNode);
//    CC_ASSERT(pTouches);
    
    if (mFingerMap.size() >= 2) {
        isMove = true;
        return;
    }
    
    if( this->mTouchMode == TouchMode_Fling )
    {
        this->m_TargetNode->stopActionByTag(FLINGACTION_TAG);
    }
    this->mTouchMode = TouchMode_None;
    
    
    for ( auto &item: pTouches )
    {
        Touch* curTouch = dynamic_cast<Touch*>(item);
        CC_ASSERT(curTouch);
        if (mFingerMap.size() <= 2) {
            mFingerMap[curTouch->getID()] = curTouch->getLocation();
        }
    }
    
    switch(mFingerMap.size())
    {
        case 1:            
        {
            m_bTouchMoved = false;
            if (this->mTouchMode != TouchMode_ZoomFling) {
                this->mTouchMode = TouchMode_Scroll;
            }

            if (!mForceStopScroll && mMovable) {
                Touch* objTouch = dynamic_cast<Touch*>(*pTouches.begin());
                CC_ASSERT(objTouch);
                // let "beginScroll" fired by first step scroll , make single touch not fire this
                //                beginScroll(objTouch);
                if (mTouchBeginHandler) {
                    pushValueToLua(mTouchBeginHandler, objTouch);
                }
            }
            
            Touch* ptouch =getAnyTouchObject(pTouches);
            mPreviewPos = ptouch->getLocation();
        }
            break;
        case 2:
            if (this->mTouchMode != TouchMode_ZoomFling) {
                this->mTouchMode = TouchMode_Zoom;
            }
            if(!allowZoom){
                return;
            }
            do
            {
                FingerMap::iterator iter = mFingerMap.begin();
                CC_BREAK_IF(iter == mFingerMap.end());
                Vec2 pos1 = (*iter).second;
                CC_BREAK_IF(++iter == mFingerMap.end());
                Vec2 pos2 = (*iter).second;
                beginZoom(pos1, pos2);
            }
            while(0);
            isMove = true;
            break;
        default:
            isMove = true;
            CCLOG("begin:Touch not support with %lu fingers", pTouches.size());
    }
}
开发者ID:ourgames,项目名称:nbg,代码行数:74,代码来源:Viewport.cpp


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