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


C++ CCTouchDispatcher类代码示例

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


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

示例1: CCAssert

void CCDirector::setOpenGLView(CC_GLVIEW *pobOpenGLView)
{
	CCAssert(pobOpenGLView, "opengl view should not be null");

	if (m_pobOpenGLView != pobOpenGLView)
	{
		// because EAGLView is not kind of CCObject
		delete m_pobOpenGLView; // [openGLView_ release]
		m_pobOpenGLView = pobOpenGLView;

		// set size
		m_obWinSizeInPoints = m_pobOpenGLView->getSize();
		m_obWinSizeInPixels = CCSizeMake(m_obWinSizeInPoints.width * m_fContentScaleFactor, m_obWinSizeInPoints.height * m_fContentScaleFactor);
        setGLDefaultValues();

		if (m_fContentScaleFactor != 1)
		{
			updateContentScaleFactor();
		}

 		CCTouchDispatcher *pTouchDispatcher = CCTouchDispatcher::sharedDispatcher();
 		m_pobOpenGLView->setTouchDelegate(pTouchDispatcher);
        pTouchDispatcher->setDispatchEvents(true);
	}
}
开发者ID:Double2,项目名称:IAPDevelop,代码行数:25,代码来源:CCDirector.cpp

示例2: claimTouch

KDvoid CCScrollLayer::claimTouch ( CCTouch* pTouch )
{
	CCTouchDispatcher*	pDispatcher = CCDirector::sharedDirector ( )->getTouchDispatcher ( );
	CCArray*			pTargetedHandlers = pDispatcher->getTargetedHandlers ( );

	// Enumerate through all targeted handlers.
	CCObject*	pObject;
	CCARRAY_FOREACH ( pTargetedHandlers, pObject )
	{
		CCTargetedTouchHandler*		pHandler = (CCTargetedTouchHandler*) pObject;
		
		// Only our handler should claim the touch.
		if ( pHandler->getDelegate ( ) == this )
		{
			if ( !pHandler->getClaimedTouches ( )->containsObject ( pTouch ) )
			{
				pHandler->getClaimedTouches ( )->addObject ( pTouch );
			}
		}
		else
		{
			// Steal touch from other targeted delegates, if they claimed it.
			if ( pHandler->getClaimedTouches ( )->containsObject ( pTouch ) )
			{
				if ( pHandler->getDelegate ( ) )
				{
					pHandler->getDelegate ( )->ccTouchEnded ( pTouch, KD_NULL );
				}

				pHandler->getClaimedTouches ( )->removeObject ( pTouch );
			}
		}
	}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:33,代码来源:CCScrollLayer.cpp

示例3: touchDelegateRelease

void CardSprite::touchDelegateRelease()
{
    
    CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher();
    pDispatcher->removeDelegate(this);
    this->release();
}
开发者ID:rick00young,项目名称:HuanHuan,代码行数:7,代码来源:CardSprite.cpp

示例4: onExit

void TapSprite::onExit()
{
    CCSprite::onExit();
    CCTouchDispatcher* dispatcher =
        CCDirector::sharedDirector()->getTouchDispatcher();
    dispatcher->removeDelegate(this);
}
开发者ID:ytworks,项目名称:private,代码行数:7,代码来源:HelloWorldScene.cpp

示例5: onEnter

void TapSprite::onEnter()
{
    CCSprite::onEnter();
    CCTouchDispatcher* dispatcher =
            CCDirector::sharedDirector()->getTouchDispatcher();
    dispatcher->addTargetedDelegate(this, 0, true);
}
开发者ID:ytworks,项目名称:private,代码行数:7,代码来源:HelloWorldScene.cpp

示例6: registerWithTouchDispatcher

void CCLayer::registerWithTouchDispatcher()
{
    CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher();

    // Using LuaBindings
    if (m_pScriptTouchHandlerEntry)
    {
        if (m_pScriptTouchHandlerEntry->isMultiTouches())
        {
            pDispatcher->addStandardDelegate(this, 0);
            LUALOG("[LUA] Add multi-touches event handler: %d", m_pScriptTouchHandlerEntry->getHandler());
        }
        else
        {
            pDispatcher->addTargetedDelegate(this,
                                             m_pScriptTouchHandlerEntry->getPriority(),
                                             m_pScriptTouchHandlerEntry->getSwallowsTouches());
            LUALOG("[LUA] Add touch event handler: %d", m_pScriptTouchHandlerEntry->getHandler());
        }
    }
    else
    {
        if( m_eTouchMode == kCCTouchesAllAtOnce ) {
            pDispatcher->addStandardDelegate(this, 0);
        } else {
            pDispatcher->addTargetedDelegate(this, m_nTouchPriority, true);
        }
    }
}
开发者ID:BetaS,项目名称:cocos2d-x,代码行数:29,代码来源:CCLayer.cpp

示例7:

HelloWorld::~HelloWorld()
{
	//remove it 
	CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher();
	pDispatcher->removeDelegate(m_pGUI);
	//release
	m_pGUI->release();
}
开发者ID:tonyhu1983,项目名称:Cobra2d,代码行数:8,代码来源:HelloWorldScene.cpp

示例8: registerWithTouchDispatcher

void CCLayer::registerWithTouchDispatcher()
{
    CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher();

    if( m_eTouchMode == kCCTouchesAllAtOnce ) {
        pDispatcher->addStandardDelegate(this, 0);
    } else {
        pDispatcher->addTargetedDelegate(this, m_nTouchPriority, m_bSwallowTouch);
    }
}
开发者ID:doom20082004,项目名称:cocos2dx-classical,代码行数:10,代码来源:CCLayer.cpp

示例9: setTouchPriority

void CWidgetLayout::setTouchPriority(int nTouchPriority)
{
	if( m_nTouchPriority != nTouchPriority )
	{
		m_nTouchPriority = nTouchPriority;
		if( m_bTouchEnabled && m_bRunning )
		{
			CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher();
			pDispatcher->setPriority(nTouchPriority, this);
		}
	}
}
开发者ID:54993306,项目名称:Classes,代码行数:12,代码来源:WidgetLayout.cpp

示例10: registerWithTouchDispatcher

		void TouchComponent::registerWithTouchDispatcher( )
		{
			CCTouchDispatcher *pDispatcher = CCDirector::sharedDirector( )->getTouchDispatcher( );

			if ( _touchMode == ALL_AT_ONCE )
			{
				pDispatcher->addStandardDelegate( this, 0 );
			} else
			{
				pDispatcher->addTargetedDelegate( this, _touchPriority, _swallowsTouches );
			}
		}
开发者ID:edwardandy,项目名称:KylinMobile,代码行数:12,代码来源:TouchComponent.cpp

示例11: cleanup

void CCTouchInjector::cleanup()
{
	if (m_Enabled)
	{
		CCTouchDispatcher* td = CCTouchDispatcher::sharedDispatcher();
		td->injectTouches(m_Touches, CCTOUCHCANCELLED);
		td->unholdUserTouch();
		m_Enabled = false;
	}

	setEnabled(false);

	CCNode::cleanup();
}
开发者ID:noriter,项目名称:nit,代码行数:14,代码来源:CCTouchDispatcher.cpp

示例12: setEnabled

void CCTouchInjector::setEnabled(bool flag)
{
	if (m_Enabled == flag) return;

	CCTouchDispatcher* td = CCTouchDispatcher::sharedDispatcher();

	if (flag)
	{
		td->holdUserTouch();
		td->injectTouches(m_Touches, CCTOUCHBEGAN);
	}
	else
	{
		td->injectTouches(m_Touches, CCTOUCHENDED);
		td->unholdUserTouch();
	}
}
开发者ID:noriter,项目名称:nit,代码行数:17,代码来源:CCTouchDispatcher.cpp

示例13: claimTouch

	/** Hackish stuff - stole touches from other CCTouchDispatcher targeted delegates. 
	 Used to claim touch without receiving ccTouchBegan. */
	void UIScrollLayer::claimTouch(CCTouch* pTouch)
	{
		CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher();
		CCTargetedTouchHandler* handler = (CCTargetedTouchHandler*)pDispatcher->findHandler(this);		
		if (handler)
		{
			CCSet* claimedTouches = handler->getClaimedTouches();
			if (!claimedTouches->containsObject(pTouch))
			{
				claimedTouches->addObject(pTouch);
			}
			else 
			{
				CCLOGERROR("CCScrollLayer::claimTouch is already claimed!");
			}
		}
	}
开发者ID:niuzb,项目名称:hellopet,代码行数:19,代码来源:UIScrollLayer.cpp

示例14: stop

void TouchGrabber::update(float delta)
{
    mPlayDeltaTime += delta;

    if (bPlaying == false) return;

    if (mTouchVecIndice >= mTouchesRecVector.size()) {
        stop();
        return;
    }

    TouchRecord rec = mTouchesRecVector.at(mTouchVecIndice);
    ///CCLOG("rec time: %f play dt: %f",rec.time / 1000.f, mPlayDeltaTime);

    if (rec.time / 1000.f > mPlayDeltaTime) return;

    CCTouchDispatcher *dispatcher = CCDirector::sharedDirector()->getTouchDispatcher();
    CCSet set;
    switch (rec.event) {
        case kTouchBegan:
            mTouch = new CCTouch(); /// Touch will be destroyed when ended/cancelled
            mTouch->setTouchInfo(0, rec.x, rec.y);
            set.addObject(mTouch);
            dispatcher->touchesBegan(&set, NULL);
            break;
        case kTouchMoved:
            mTouch->setTouchInfo(0, rec.x, rec.y);
            set.addObject(mTouch);
            dispatcher->touchesMoved(&set, NULL);
            break;
        case kTouchEnded:
            mTouch->setTouchInfo(0, rec.x, rec.y);
            set.addObject(mTouch);
            dispatcher->touchesEnded(&set, NULL);
            break;
        case kTouchCancelled:
            mTouch->setTouchInfo(0, rec.x, rec.y);
            set.addObject(mTouch);
            dispatcher->touchesCancelled(&set, NULL);
            break;
        default: CCAssert(false, "Unknown touch event."); break;
    }
    mTouchVecIndice++;
}
开发者ID:xoraphics,项目名称:yummyjump,代码行数:44,代码来源:touchgrabber.cpp

示例15: registerWithTouchDispatcher

void CCLayer::registerWithTouchDispatcher()
{
	CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher();

    if (m_pScriptHandlerEntry)
    {
        if (m_pScriptHandlerEntry->isMultiTouches())
        {
            pDispatcher->addStandardDelegate(this,0);
            LUALOG("[LUA] Add multi-touches event handler: %d", m_pScriptHandlerEntry->getHandler());
        }
        else
        {
            pDispatcher->addTargetedDelegate(this,
                                                                       m_pScriptHandlerEntry->getPriority(),
                                                                       m_pScriptHandlerEntry->getSwallowsTouches());
            LUALOG("[LUA] Add touch event handler: %d", m_pScriptHandlerEntry->getHandler());
        }
        return;
    }
	pDispatcher->addStandardDelegate(this,0);
}
开发者ID:qiuxu,项目名称:Cocos2dWindows,代码行数:22,代码来源:CCLayer.cpp


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