コード例 #1
0
ファイル: CCEGLViewProtocol.cpp プロジェクト: korman/Temp
void CCEGLViewProtocol::getSetOfTouchesEndOrCancel(CCSet& set, int num,
												   int ids[], float xs[], float ys[])
{
	for (int i = 0; i < num; ++i)
	{
		int id = ids[i];
		float x = xs[i];
		float y = ys[i];

		CCInteger* pIndex = (CCInteger*) s_TouchesIntergerDict.objectForKey(id);
		if (pIndex == NULL)
		{
			CCLOG("if the index doesn't exist, it is an error");
			continue;
		}
		/* Add to the set to send to the director */
		CCTouch* pTouch = s_pTouches[pIndex->getValue()];
		if (pTouch)
		{
			CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y);

			if (m_bIsRetinaEnabled)
			{
				pTouch->setTouchInfo(pIndex->getValue(),
					(x - m_obViewPortRect.origin.x),
					(y - m_obViewPortRect.origin.y));
			}
			else
			{
				pTouch->setTouchInfo(pIndex->getValue(),
					(x - m_obViewPortRect.origin.x) / m_fScaleX,
					(y - m_obViewPortRect.origin.y) / m_fScaleY);
			}

			set.addObject(pTouch);

			// release the object
			pTouch->release();
			s_pTouches[pIndex->getValue()] = NULL;
			removeUsedIndexBit(pIndex->getValue());

			s_TouchesIntergerDict.removeObjectForKey(id);

		}
		else
		{
			CCLOG("Ending touches with id: %d error", id);
			return;
		}

	}

	if (set.count() == 0)
	{
		CCLOG("touchesEnded or touchesCancel: count = 0");
		return;
	}
}
コード例 #2
0
ファイル: MutiTouchTest.cpp プロジェクト: csdnnet/hiygame
void MutiTouchTestLayer::ccTouchesEnded(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());
        removeChild(pTP, true);
        s_dic.removeObjectForKey(pTouch->getID());
    }
}
コード例 #3
0
ファイル: App.cpp プロジェクト: andrew889/proton_cm_open
void App::HandleTouchesEnd(int num, int ids[], float xs[], float ys[])
{
	int			i;
	int			id;
    float		x;
    float		y;
	CCSet		set;
	CCTouch*	pTouch;
	CCInteger*	pIndex;
	
	for (i = 0; i < num; ++i)
    {
        id	= ids[i];
        x	= xs[i];
        y	= ys[i];

        pIndex = (CCInteger*)s_TouchesIntergerDict.objectForKey(id);
        if (pIndex == NULL)
        {
            CCLOG("if the index doesn't exist, it is an error");
            continue;
        }
        
        pTouch = s_pTouches[pIndex->getValue()];        
		if (pTouch)
        {
            CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y);
			pTouch->setTouchInfo(pIndex->getValue(), x, y);

            set.addObject(pTouch);

            // release the object
            pTouch->release();
            s_pTouches[pIndex->getValue()] = NULL;
            removeUsedIndexBit(pIndex->getValue());

            s_TouchesIntergerDict.removeObjectForKey(id);
        } 
        else
        {
            CCLOG("Ending touches with id: %d error", id);
            return;
        } 

    }

    CCDirector::sharedDirector()->getTouchDispatcher()->touchesEnded(&set, NULL);
}