本文整理汇总了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);
}
}
示例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 );
}
}
}
示例3: touchDelegateRelease
void CardSprite::touchDelegateRelease()
{
CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher();
pDispatcher->removeDelegate(this);
this->release();
}
示例4: onExit
void TapSprite::onExit()
{
CCSprite::onExit();
CCTouchDispatcher* dispatcher =
CCDirector::sharedDirector()->getTouchDispatcher();
dispatcher->removeDelegate(this);
}
示例5: onEnter
void TapSprite::onEnter()
{
CCSprite::onEnter();
CCTouchDispatcher* dispatcher =
CCDirector::sharedDirector()->getTouchDispatcher();
dispatcher->addTargetedDelegate(this, 0, true);
}
示例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);
}
}
}
示例7:
HelloWorld::~HelloWorld()
{
//remove it
CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher();
pDispatcher->removeDelegate(m_pGUI);
//release
m_pGUI->release();
}
示例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);
}
}
示例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);
}
}
}
示例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 );
}
}
示例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();
}
示例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();
}
}
示例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!");
}
}
}
示例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++;
}
示例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);
}