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


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

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


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

示例1: onTouchesMove

void CCEGLView::onTouchesMove(int id[], float x[], float y[], int pointerNumber)
{
	result r = E_SUCCESS;
	CCSet set;
	for(int i = 0 ; i < pointerNumber ; i++ ) {
		CCLOG("Moving touches with id: %d, x=%f, y=%f", id[i], x[i], y[i]);
		CCTouch *pTouch = NULL;
		r = s_mapTouches.GetValue(id[i], pTouch);

		if (E_SUCCESS == r && pTouch != NULL)
		{
			pTouch->SetTouchInfo(0, (x[i] - m_rcViewPort.origin.x) / m_fScreenScaleFactor ,
								(y[i] - m_rcViewPort.origin.y) / m_fScreenScaleFactor);
			set.addObject(pTouch);
		}
		else
		{
			// It is error, should return.
			CCLOG("Moving touches with id: %d error", id[i]);
			return;
		}
	}

	m_pDelegate->touchesMoved(&set, NULL);
}
开发者ID:Avnerus,项目名称:ichigo,代码行数:25,代码来源:CCEGLView_bada.cpp

示例2: OnPointerPressed

void CCEGLView::OnPointerPressed(int id, const CCPoint& point)
{
    // prepare CCTouch
    CCTouch* pTouch = m_pTouches[id];
    if (! pTouch)
    {
        pTouch = new CCTouch();
        m_pTouches[id] = pTouch;
    }

    // prepare CCSet
    CCSet* pSet = m_pSets[id];
    if (! pSet)
    {
        pSet = new CCSet();
        m_pSets[id] = pSet;
    }

    if (! pTouch || ! pSet)
        return;

    float x = point.x;
    float y = point.y;
    ConvertPointerCoords(x, y);
    pTouch->SetTouchInfo(x, y);
    pSet->addObject(pTouch);

    m_pDelegate->touchesBegan(pSet, NULL);
}
开发者ID:9miao,项目名称:cocos2dx-win8,代码行数:29,代码来源:CCEGLView_win8_metro.cpp

示例3: OnPenUp

Boolean CCXEGLView::OnPenUp(EventType* pEvent, Int32 nIndex)
{
    if (m_pDelegate && nIndex < MAX_TOUCHES)
    {
        CCTouch* pTouch = s_pTouches[nIndex];
        if (pTouch)
        {
            NSSet set;
            pTouch->SetTouchInfo(0, (float)pEvent->sParam1, (float)pEvent->sParam2);
            set.addObject(pTouch);
            m_pDelegate->touchesEnded(&set, NULL);

            pTouch->release();
            for (Int32 i = nIndex; i < MAX_TOUCHES; ++i)
            {
                if (i != (MAX_TOUCHES - 1))
                {
                    s_pTouches[i] = s_pTouches[i + 1];
                }
                else
                {
                    s_pTouches[i] = NULL;
                }
            }
        }
    }

    return FALSE;
}
开发者ID:geniikw,项目名称:myFirst2DGame,代码行数:29,代码来源:CCXEGLView_uphone.cpp

示例4: OnPenMove

Boolean CCEGLView::OnPenMove(EventType* pEvent)
{
    do 
    {
        CC_BREAK_IF(!m_pDelegate);

        Int32 nCount = EvtGetPenMultiPointCount(pEvent);
        CC_BREAK_IF(nCount <= 0 || nCount > MAX_TOUCHES);

        CCSet set;
        Int32 nPosX, nPosY;
        for (Int32 i = 0; i < nCount; ++i)
        {
            CCTouch* pTouch = s_pTouches[i];
            CC_BREAK_IF(!pTouch);

            EvtGetPenMultiPointXY(pEvent, i, &nPosX, &nPosY);
            pTouch->SetTouchInfo(0, (float) nPosX, (float) nPosY);
            set.addObject(pTouch);
        }

        m_pDelegate->touchesMoved(&set, NULL);
    } while (0);

    return FALSE;
}
开发者ID:BigHand,项目名称:cocos2d-x,代码行数:26,代码来源:CCEGLView_uphone.cpp

示例5: OnPenUp

Boolean CCEGLView::OnPenUp(EventType* pEvent, Int32 nIndex)
{
    if (m_pDelegate && nIndex < MAX_TOUCHES)
    {
        CCTouch* pTouch = s_pTouches[nIndex];
        if (pTouch)
        {
            CCSet set;
            pTouch->SetTouchInfo(0, (float)(pEvent->sParam1 - m_rcViewPort.X()) / m_fScreenScaleFactor,
                                 (float)(pEvent->sParam2 - m_rcViewPort.Y()) / m_fScreenScaleFactor);
            set.addObject(pTouch);
            m_pDelegate->touchesEnded(&set, NULL);

            pTouch->release();
            for (Int32 i = nIndex; i < MAX_TOUCHES; ++i)
            {
                if (i != (MAX_TOUCHES - 1))
                {
                    s_pTouches[i] = s_pTouches[i + 1];
                }
                else
                {
                    s_pTouches[i] = NULL;
                }
            }
        }
    }

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

示例6: OnPointerMoved

void CCEGLView::OnPointerMoved(int id, const CCPoint& point)
{
    CCTouch* pTouch = m_pTouches[id];
    CCSet* pSet = m_pSets[id];
    
    if (! pTouch || ! pSet)
        return;

    float x = point.x;
    float y = point.y;
    ConvertPointerCoords(x, y);
    pTouch->SetTouchInfo(x, y);

    m_pDelegate->touchesMoved(pSet, NULL);
}
开发者ID:9miao,项目名称:cocos2dx-win8,代码行数:15,代码来源:CCEGLView_win8_metro.cpp

示例7: OnPointerOn

void CCTouchDispatcher::OnPointerOn(const InputPointerEvent* evt)
{
	CCSet set;
	CCTouch* pTouch = new CCTouch();

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

	set.addObject(pTouch);

	m_Touches.insert(std::make_pair(evt->getSource(), pTouch));
	pTouch->retain();

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

	touchesBegan(&set);
}
开发者ID:noriter,项目名称:nit,代码行数:16,代码来源:CCTouchDispatcher.cpp

示例8: OnPointerDrag

void CCTouchDispatcher::OnPointerDrag(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;

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

	set.addObject(pTouch);

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

	touchesMoved(&set);
}
开发者ID:noriter,项目名称:nit,代码行数:17,代码来源:CCTouchDispatcher.cpp

示例9: OnPenDown

Boolean CCXEGLView::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, (float)pEvent->sParam2);
        s_pTouches[nIndex] = pTouch;
        NSSet set;
        set.addObject(pTouch);
        m_pDelegate->touchesBegan(&set, NULL);
    }

    return FALSE;
}
开发者ID:geniikw,项目名称:myFirst2DGame,代码行数:19,代码来源:CCXEGLView_uphone.cpp

示例10: OnPointerReleased

void CCEGLView::OnPointerReleased(int id, const CCPoint& point)
{
    CCTouch* pTouch = m_pTouches[id];
    CCSet* pSet = m_pSets[id];

    if (! pTouch || ! pSet)
        return;

    float x = point.x;
    float y = point.y;
    ConvertPointerCoords(x, y);
    pTouch->SetTouchInfo(x, y);

    m_pDelegate->touchesEnded(pSet, NULL);
    pSet->removeObject(pTouch);

    CC_SAFE_DELETE(m_pTouches[id]);
    CC_SAFE_DELETE(m_pSets[id]);
}
开发者ID:9miao,项目名称:cocos2dx-win8,代码行数:19,代码来源:CCEGLView_win8_metro.cpp

示例11: onTouchesEnd

void CCEGLView::onTouchesEnd(int id[], float x[], float y[], int pointerNumber)
{
	result r = E_SUCCESS;
	CCSet set;
	for(int i = 0 ; i < pointerNumber ; i++ ) {
		CCTouch *pTouch = NULL;
		r = s_mapTouches.GetValue(id[i], pTouch);
		if (E_SUCCESS == r && pTouch != NULL)
		{
			pTouch->SetTouchInfo(0, (x[i] - m_rcViewPort.origin.x) / m_fScreenScaleFactor ,
		                        (y[i] - m_rcViewPort.origin.y) / m_fScreenScaleFactor);
			set.addObject(pTouch);
			s_mapTouches.Remove(id[i]);
			pTouch->release();
			CCLOG("Ending touches with id: %d, x=%f, y=%f, retain count = %d", id[i], x[i], y[i], pTouch->retainCount());
		}
	}

	m_pDelegate->touchesEnded(&set, NULL);
}
开发者ID:Avnerus,项目名称:ichigo,代码行数:20,代码来源:CCEGLView_bada.cpp

示例12: 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

示例13: onTouchesBegin

void CCEGLView::onTouchesBegin(int id[], float x[], float y[], int pointerNumber)
{
	result r = E_SUCCESS;
	CCSet set;
	for(int i = 0 ; i < pointerNumber ; i++ ) {
		CCTouch *pTouch = NULL;
		r = s_mapTouches.GetValue(id[i], pTouch);
		if (E_OBJ_NOT_FOUND == r && NULL == pTouch)
		{
			pTouch = new CCTouch();
			pTouch->SetTouchInfo(0, (x[i] - m_rcViewPort.origin.x) / m_fScreenScaleFactor, (y[i] - m_rcViewPort.origin.y) / m_fScreenScaleFactor);
			s_mapTouches.Add(id[i], pTouch);
			set.addObject(pTouch);
			m_pDelegate->touchesBegan(&set, NULL);
		}
		else
		{
			CCLOG("Beginnig touches with id: %d error", id[i]);
		}
	}
}
开发者ID:Avnerus,项目名称:ichigo,代码行数:21,代码来源:CCEGLView_bada.cpp

示例14: CCTouch

    // handle touch event	
	void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin(JNIEnv*  env, jobject thiz, jint id, jfloat x, jfloat y)
	{
		CCRect rcRect = CCEGLView::sharedOpenGLView().getViewPort();
		CCSet set;

		CCTouch *pTouch = s_pTouches[id];
		if (! pTouch)
		{
			LOGD("Beginning touches with id: %d, x=%f, y=%f", id, x, y);

			pTouch = new CCTouch();			
			pTouch->SetTouchInfo(0, x - rcRect.origin.x, y - rcRect.origin.y, id);
			s_pTouches[id] = pTouch;
			set.addObject(pTouch);

			cocos2d::CCDirector::sharedDirector()->getOpenGLView()->getDelegate()->touchesBegan(&set, NULL);
		}	
		else
		{
			LOGD("Beginnig touches with id: %d error", id);
		}
	}
开发者ID:authorly,项目名称:interapptive,代码行数:23,代码来源:TouchesJni.cpp

示例15:

	void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd(JNIEnv*  env, jobject thiz, jint id, jfloat x, jfloat y)
	{
		CCRect rcRect = CCEGLView::sharedOpenGLView().getViewPort();
		CCSet set;

		/* Add to the set to send to the director */
		CCTouch* pTouch = s_pTouches[id];		
		if (pTouch)
		{
			LOGD("Ending touches with id: %d, x=%f, y=%f", id, x, y);

			pTouch->SetTouchInfo(0, x - rcRect.origin.x , y - rcRect.origin.y, id);
		    set.addObject(pTouch);

			// release the object
			pTouch->release();
			s_pTouches[id] = NULL;

			cocos2d::CCDirector::sharedDirector()->getOpenGLView()->getDelegate()->touchesEnded(&set, NULL);
		} else {
			LOGD("Ending touches with id: %d error", id);
		}		
	}
开发者ID:authorly,项目名称:interapptive,代码行数:23,代码来源:TouchesJni.cpp


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