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


C++ CCSet::count方法代码示例

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


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

示例1: handleTouchesBegin

void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[],
										   float ys[])
{
	CCSet set;
	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);
		int nUnusedIndex = 0;

		// it is a new touch
		if (pIndex == NULL)
		{
			nUnusedIndex = getUnUsedIndex();

			// The touches is more than MAX_TOUCHES ?
			if (nUnusedIndex == -1)
			{
				CCLOG("The touches is more than MAX_TOUCHES, nUnusedIndex = %d",
					nUnusedIndex);
				continue;
			}

			CCTouch* pTouch = s_pTouches[nUnusedIndex] = new CCTouch();
			if (m_bIsRetinaEnabled)
			{
				// on iOS, though retina is enabled, the value got from os is also 
				// relative to its original size
				pTouch->setTouchInfo(nUnusedIndex,
					(x - m_obViewPortRect.origin.x),
					(y - m_obViewPortRect.origin.y));
			}
			else
			{
				pTouch->setTouchInfo(nUnusedIndex,
					(x - m_obViewPortRect.origin.x) / m_fScaleX,
					(y - m_obViewPortRect.origin.y) / m_fScaleY);
			}

			//CCLOG("x = %f y = %f", pTouch->getLocationInView().x, pTouch->getLocationInView().y);

			CCInteger* pInterObj = new CCInteger(nUnusedIndex);
			s_TouchesIntergerDict.setObject(pInterObj, id);
			set.addObject(pTouch);
			pInterObj->release();
		}
	}

	if (set.count() == 0)
	{
		CCLOG("touchesBegan: count = 0");
		return;
	}

	m_pDelegate->touchesBegan(&set, NULL);
}
开发者ID:korman,项目名称:Temp,代码行数:59,代码来源:CCEGLViewProtocol.cpp

示例2: getSetOfTouchesEndOrCancel

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;
	}
}
开发者ID:korman,项目名称:Temp,代码行数:58,代码来源:CCEGLViewProtocol.cpp

示例3: handleTouchesMove

void CCEGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[],
										  float ys[])
{
	CCSet set;
	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;
		}

		CCLOGINFO("Moving touches with id: %d, x=%f, y=%f", id, x, y);
		CCTouch* pTouch = s_pTouches[pIndex->getValue()];
		if (pTouch)
		{
			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);
		}
		else
		{
			// It is error, should return.
			CCLOG("Moving touches with id: %d error", id);
			return;
		}
	}

	if (set.count() == 0)
	{
		CCLOG("touchesMoved: count = 0");
		return;
	}

	m_pDelegate->touchesMoved(&set, NULL);
}
开发者ID:korman,项目名称:Temp,代码行数:52,代码来源:CCEGLViewProtocol.cpp

示例4: handleTouchesBegin

void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[])
{
    CCSet set;
    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);
        int nUnusedIndex = 0;

        // it is a new touch
        if (pIndex == NULL)
        {
            nUnusedIndex = getUnUsedIndex();

            // The touches is more than MAX_TOUCHES ?
            if (nUnusedIndex == -1) {
                CCLOG("The touches is more than MAX_TOUCHES, nUnusedIndex = %d", nUnusedIndex);
                continue;
            }

            CCTouch* pTouch = s_pTouches[nUnusedIndex] = new CCTouch();
			pTouch->setTouchInfo(nUnusedIndex, (x - m_obViewPortRect.origin.x) / m_fScaleX, 
                                     (y - m_obViewPortRect.origin.y) / m_fScaleY);
            
            //CCLOG("x = %f y = %f", pTouch->getLocationInView().x, pTouch->getLocationInView().y);
            
            CCInteger* pInterObj = new CCInteger(nUnusedIndex);
            s_TouchesIntergerDict.setObject(pInterObj, id);
            set.addObject(pTouch);
            pInterObj->release();
        }
    }

    if (set.count() == 0)
    {
        CCLOG("touchesBegan: count = 0");
        return;
    }

    CCEvent event;
    CCSet *allTouches= new CCSet;
    allTouches->autorelease();
    getCurrentSetOfTouches(*allTouches);
    event.setAllTouches(allTouches);
    m_pDelegate->touchesBegan(&set, &event);
}
开发者ID:vedi,项目名称:cocos2d-x,代码行数:49,代码来源:CCEGLViewProtocol.cpp

示例5: HandleTouchesBegin

void App::HandleTouchesBegin(int num, int ids[], float xs[], float ys[])
{
	int			i;
	int			id;
	int			nUnusedIndex;
    float		x;
    float		y;
	CCSet		set;
	CCTouch*	pTouch;
	CCInteger*	pIndex;
	CCInteger*	pInterObj;

    for (i = 0; i < num; ++i)
    {
        id	= ids[i];
        x	= xs[i];
        y	= ys[i];

        pIndex = (CCInteger*)s_TouchesIntergerDict.objectForKey(id);
        nUnusedIndex = 0;

        // it is a new touch
        if (pIndex == NULL)
        {
            nUnusedIndex = getUnUsedIndex();

            // The touches is more than MAX_TOUCHES ?
            if (nUnusedIndex == -1) 
			{
                CCLOG("The touches is more than MAX_TOUCHES, nUnusedIndex = %d", nUnusedIndex);
                continue;
            }

            pTouch = s_pTouches[nUnusedIndex] = new CCTouch();
			pTouch->setTouchInfo( nUnusedIndex, x, y );
                        
            pInterObj = new CCInteger(nUnusedIndex);
            s_TouchesIntergerDict.setObject(pInterObj, id);
            set.addObject(pTouch);
            pInterObj->release();
        }
    }

    if (set.count() > 0)
    {
        CCDirector::sharedDirector()->getTouchDispatcher()->touchesBegan(&set, NULL);
    }
}
开发者ID:andrew889,项目名称:proton_cm_open,代码行数:48,代码来源:App.cpp

示例6: getSetOfTouchesEndOrCancel

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];

        CC_CONTINUE_IF(s_TouchesIntergerDict.find(id) == s_TouchesIntergerDict.end());
        int index = s_TouchesIntergerDict.at(id);

        /* Add to the set to send to the director */
        CATouch* pTouch = s_pTouches[index];
        if (pTouch)
        {
            CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y);
            pTouch->setTouchInfo(index,
                                 (x - m_obViewPortRect.origin.x) / m_fScaleX,
                                 (y - m_obViewPortRect.origin.y) / m_fScaleY);

            set.addObject(pTouch);

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

            s_TouchesIntergerDict.erase(id);

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

    }

    if (set.count() == 0)
    {
        CCLOG("touchesEnded or touchesCancel: count = 0");
        return;
    }
}
开发者ID:khjl12345,项目名称:CrossApp,代码行数:44,代码来源:CCEGLViewProtocol.cpp

示例7: HandleTouchesMove

void App::HandleTouchesMove(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;
        }

        CCLOGINFO("Moving touches with id: %d, x=%f, y=%f", id, x, y);
        pTouch = s_pTouches[pIndex->getValue()];
        
		if (pTouch)
        {
			pTouch->setTouchInfo(pIndex->getValue(), x, y);
            set.addObject(pTouch);
        }
        else
        {
            // It is error, should return.
            CCLOG("Moving touches with id: %d error", id);
            return;
        }
    }

    if (set.count() > 0)
    {
        CCDirector::sharedDirector()->getTouchDispatcher()->touchesMoved(&set, NULL);
    }
}
开发者ID:andrew889,项目名称:proton_cm_open,代码行数:44,代码来源:App.cpp

示例8: handleTouchesBegin

void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[])
{
    CCSet set;
    for (int i = 0; i < num; ++i)
    {
        int id = ids[i];
        float x = xs[i];
        float y = ys[i];

        int nUnusedIndex = 0;

        // it is a new touch
        if (s_TouchesIntergerDict.find(id) == s_TouchesIntergerDict.end())
        {
            nUnusedIndex = getUnUsedIndex();

            // The touches is more than MAX_TOUCHES ?
            if (nUnusedIndex == -1)
            {
                CCLOG("The touches is more than MAX_TOUCHES, nUnusedIndex = %d", nUnusedIndex);
                continue;
            }

            CATouch* pTouch = s_pTouches[nUnusedIndex] = new CATouch();
            pTouch->setTouchInfo(nUnusedIndex,
                                 (x - m_obViewPortRect.origin.x) / m_fScaleX,
                                 (y - m_obViewPortRect.origin.y) / m_fScaleY);


            s_TouchesIntergerDict.insert(std::make_pair(id, nUnusedIndex));
            set.addObject(pTouch);
        }
    }

    if (set.count() == 0)
    {
        CCLOG("touchesBegan: count = 0");
        return;
    }

    m_pDelegate->touchesBegan(&set, NULL);
}
开发者ID:khjl12345,项目名称:CrossApp,代码行数:42,代码来源:CCEGLViewProtocol.cpp

示例9: handleTouchesMove

void CCEGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys[])
{
    CCSet set;
    for (int i = 0; i < num; ++i)
    {
        int id = ids[i];
        float x = xs[i];
        float y = ys[i];

        CC_CONTINUE_IF(s_TouchesIntergerDict.find(id) == s_TouchesIntergerDict.end());
        int index = s_TouchesIntergerDict.at(id);

        CCLOGINFO("Moving touches with id: %d, x=%f, y=%f", id, x, y);
        CATouch* pTouch = s_pTouches[index];
        if (pTouch)
        {
            pTouch->setTouchInfo(index,
                                 (x - m_obViewPortRect.origin.x) / m_fScaleX,
                                 (y - m_obViewPortRect.origin.y) / m_fScaleY);

            set.addObject(pTouch);
        }
        else
        {
            // It is error, should return.
            CCLOG("Moving touches with id: %d error", id);
            return;
        }
    }

    if (set.count() == 0)
    {
        CCLOG("touchesMoved: count = 0");
        return;
    }

    m_pDelegate->touchesMoved(&set, NULL);
}
开发者ID:khjl12345,项目名称:CrossApp,代码行数:38,代码来源:CCEGLViewProtocol.cpp

示例10: touches

//
// dispatch events
//
void CCTouchDispatcher::touches(CCSet *pTouches, CCEvent *pEvent, unsigned int uIndex)
{
	CCAssert(uIndex >= 0 && uIndex < 4, "");

	CCSet *pMutableTouches;
	m_bLocked = true;

	// optimization to prevent a mutable copy when it is not necessary
 	unsigned int uTargetedHandlersCount = m_pTargetedHandlers->count();
 	unsigned int uStandardHandlersCount = m_pStandardHandlers->count();
	bool bNeedsMutableSet = (uTargetedHandlersCount && uStandardHandlersCount);

	pMutableTouches = (bNeedsMutableSet ? pTouches->mutableCopy() : pTouches);

	struct ccTouchHandlerHelperData sHelper = m_sHandlerHelperData[uIndex];
	//
	// process the target handlers 1st
	//
	if (uTargetedHandlersCount > 0)
	{
        CCTouch *pTouch;
		CCSetIterator setIter;
		for (setIter = pTouches->begin(); setIter != pTouches->end(); ++setIter)
		{
			pTouch = (CCTouch *)(*setIter);
			CCTargetedTouchHandler *pHandler;
			CCMutableArray<CCTouchHandler*>::CCMutableArrayIterator arrayIter;
			for (arrayIter = m_pTargetedHandlers->begin(); arrayIter != m_pTargetedHandlers->end(); ++arrayIter)
			/*for (unsigned int i = 0; i < m_pTargetedHandlers->num; ++i)*/
			{
                pHandler = (CCTargetedTouchHandler *)(*arrayIter);

                if (! pHandler)
                {
				   break;
                }

				bool bClaimed = false;
				if (uIndex == CCTOUCHBEGAN)
				{
					bClaimed = pHandler->getDelegate()->ccTouchBegan(pTouch, pEvent);

					if (bClaimed)
					{
						pHandler->getClaimedTouches()->addObject(pTouch);
					}
				} else
				if (pHandler->getClaimedTouches()->containsObject(pTouch))
				{
					// moved ended cancelled
					bClaimed = true;

					switch (sHelper.m_type)
					{
					case CCTOUCHMOVED:
						pHandler->getDelegate()->ccTouchMoved(pTouch, pEvent);
						break;
					case CCTOUCHENDED:
						pHandler->getDelegate()->ccTouchEnded(pTouch, pEvent);
						pHandler->getClaimedTouches()->removeObject(pTouch);
						break;
					case CCTOUCHCANCELLED:
						pHandler->getDelegate()->ccTouchCancelled(pTouch, pEvent);
						pHandler->getClaimedTouches()->removeObject(pTouch);
						break;
					}
				}

				if (bClaimed && pHandler->isSwallowsTouches())
				{
					if (bNeedsMutableSet)
					{
						pMutableTouches->removeObject(pTouch);
					}

					break;
				}
			}
		}
	}

	//
	// process standard handlers 2nd
	//
	if (uStandardHandlersCount > 0 && pMutableTouches->count() > 0)
	{
		CCMutableArray<CCTouchHandler*>::CCMutableArrayIterator iter;
		CCStandardTouchHandler *pHandler;
		for (iter = m_pStandardHandlers->begin(); iter != m_pStandardHandlers->end(); ++iter)
		{
			pHandler = (CCStandardTouchHandler*)(*iter);

            if (! pHandler)
            {
			    break;
            }

//.........这里部分代码省略.........
开发者ID:9miao,项目名称:cocos2dx-win8,代码行数:101,代码来源:CCTouchDispatcher.cpp


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