本文整理汇总了C++中CCDirector::getKeypadDispatcher方法的典型用法代码示例。如果您正苦于以下问题:C++ CCDirector::getKeypadDispatcher方法的具体用法?C++ CCDirector::getKeypadDispatcher怎么用?C++ CCDirector::getKeypadDispatcher使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCDirector
的用法示例。
在下文中一共展示了CCDirector::getKeypadDispatcher方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onEnter
/// Callbacks
void CCLayer::onEnter()
{
CCDirector* pDirector = CCDirector::sharedDirector();
// register 'parent' nodes first
// since events are propagated in reverse order
if (m_bTouchEnabled)
{
this->registerWithTouchDispatcher();
}
// then iterate over all the children
CCNode::onEnter();
// add this layer to concern the Accelerometer Sensor
if (m_bAccelerometerEnabled)
{
pDirector->getAccelerometer()->setDelegate(this);
}
// add this layer to concern the keypad msg
if (m_bKeypadEnabled)
{
pDirector->getKeypadDispatcher()->addDelegate(this);
}
}
示例2: setKeypadEnabled
/// isKeypadEnabled setter
void CAViewController::setKeypadEnabled(bool enabled)
{
if (enabled != m_bKeypadEnabled)
{
m_bKeypadEnabled = enabled;
CCDirector* pDirector = CCDirector::sharedDirector();
if (enabled)
{
pDirector->getKeypadDispatcher()->addDelegate(this);
}
else
{
pDirector->getKeypadDispatcher()->removeDelegate(this);
}
}
}
示例3: Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyDown
jboolean Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyDown(JNIEnv* env, jobject thiz, jint keyCode)
{
CCDirector* pDirector = CCDirector::sharedDirector();
switch (keyCode)
{
case KEYCODE_BACK:
if (pDirector->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked))
return JNI_TRUE;
break;
case KEYCODE_MENU:
if (pDirector->getKeypadDispatcher()->dispatchKeypadMSG(kTypeMenuClicked))
return JNI_TRUE;
break;
default:
return JNI_FALSE;
}
return JNI_FALSE;
}
示例4: setKeypadEnabled
/// isKeypadEnabled setter
void CCLayer::setKeypadEnabled(bool enabled)
{
if (enabled != m_bKeypadEnabled)
{
m_bKeypadEnabled = enabled;
if (m_bRunning)
{
CCDirector* pDirector = CCDirector::sharedDirector();
if (enabled)
{
pDirector->getKeypadDispatcher()->addDelegate(this);
}
else
{
pDirector->getKeypadDispatcher()->removeDelegate(this);
}
}
}
}
示例5:
CAViewController::~CAViewController()
{
m_pView->setViewDelegate(NULL);
CC_SAFE_RELEASE_NULL(m_pView);
CC_SAFE_DELETE(m_pTabBarItem);
CC_SAFE_DELETE(m_pNavigationBarItem);
CCDirector* pDirector = CCDirector::sharedDirector();
if (m_bKeypadEnabled)
{
pDirector->getKeypadDispatcher()->removeDelegate(this);
}
}
示例6: switch
JNIEXPORT jboolean JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyEvent(JNIEnv * env, jobject thiz, jint keyCode, jint keyType) {
int key = kCodeUnknown;
switch (keyCode) {
case KEYCODE_BACK:
key = kCodeBack;
break;
case KEYCODE_MENU:
key = kCodeMenu;
break;
case KEYCODE_ENTER:
case KEYCODE_DPAD_CENTER:
key = kCodeEnter;
break;
case KEYCODE_DPAD_UP:
key = kCodeUp;
break;
case KEYCODE_DPAD_DOWN:
key = kCodeDown;
break;
case KEYCODE_DPAD_LEFT:
key = kCodeLeft;
break;
case KEYCODE_DPAD_RIGHT:
key = kCodeRight;
break;
case KEYCODE_VOLUME_UP:
key = kCodeVolUp;
break;
case KEYCODE_VOLUME_DOWN:
key = kCodeVolDown;
break;
default:
return JNI_FALSE;
}
CCDirector* pDirector = CCDirector::sharedDirector();
if (pDirector->getKeypadDispatcher()->dispatchKeypadEvent(key, keyType)) {
return JNI_TRUE;
}
return JNI_FALSE;
}
示例7: onExit
void CCLayer::onExit()
{
CCDirector* pDirector = CCDirector::sharedDirector();
if( m_bIsTouchEnabled )
{
pDirector->getTouchDispatcher()->removeDelegate(this);
unregisterScriptTouchHandler();
}
// remove this layer from the delegates who concern Accelerometer Sensor
if (m_bIsAccelerometerEnabled)
{
pDirector->getAccelerometer()->setDelegate(NULL);
}
// remove this layer from the delegates who concern the kaypad msg
if (m_bIsKeypadEnabled)
{
pDirector->getKeypadDispatcher()->removeDelegate(this);
}
CCNode::onExit();
}
示例8: onExit
void CCLayer::onExit()
{
CCDirector* pDirector = CCDirector::sharedDirector();
if( m_bTouchEnabled )
{
pDirector->getTouchDispatcher()->removeDelegate(this);
// [lua]:don't unregister script touch handler, or the handler will be destroyed
// unregisterScriptTouchHandler();
}
// remove this layer from the delegates who concern Accelerometer Sensor
if (m_bAccelerometerEnabled)
{
pDirector->getAccelerometer()->setDelegate(NULL);
}
// remove this layer from the delegates who concern the keypad msg
if (m_bKeypadEnabled)
{
pDirector->getKeypadDispatcher()->removeDelegate(this);
}
CCNode::onExit();
}
示例9: WindowProc
//.........这里部分代码省略.........
else if (ti.dwFlags & TOUCHEVENTF_MOVE)
handleTouchesMove(1, reinterpret_cast<int*>(&ti.dwID), &pt.x, &pt.y);
else if (ti.dwFlags & TOUCHEVENTF_UP)
handleTouchesEnd(1, reinterpret_cast<int*>(&ti.dwID), &pt.x, &pt.y);
}
}
bHandled = TRUE;
}
delete [] pInputs;
}
if (bHandled)
{
s_pfCloseTouchInputHandleFunction((HTOUCHINPUT)lParam);
}
}
break;
#endif /* #if(_MSC_VER >= 1600) */
case WM_SIZE:
switch (wParam)
{
case SIZE_RESTORED:
CCApplication::sharedApplication()->applicationWillEnterForeground();
break;
case SIZE_MINIMIZED:
CCApplication::sharedApplication()->applicationDidEnterBackground();
break;
}
break;
case WM_KEYDOWN:
if (wParam == VK_F1 || wParam == VK_F2)
{
CCDirector* pDirector = CCDirector::sharedDirector();
if (GetKeyState(VK_LSHIFT) < 0 || GetKeyState(VK_RSHIFT) < 0 || GetKeyState(VK_SHIFT) < 0)
pDirector->getKeypadDispatcher()->dispatchKeypadMSG(wParam == VK_F1 ? kTypeBackClicked : kTypeMenuClicked);
}
if ( m_lpfnAccelerometerKeyHook!=NULL )
{
(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
}
break;
case WM_KEYUP:
if ( m_lpfnAccelerometerKeyHook!=NULL )
{
(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
}
break;
case WM_CHAR:
{
if (wParam < 0x20)
{
if (VK_BACK == wParam)
{
CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
}
else if (VK_RETURN == wParam)
{
CCIMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1);
}
else if (VK_TAB == wParam)
{
// tab input
}
else if (VK_ESCAPE == wParam)
{
// ESC input
//CCDirector::sharedDirector()->end();
示例10: WindowProc
LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
BOOL bProcessed = FALSE;
switch (message)
{
case WM_LBUTTONDOWN:
if (m_pDelegate && MK_LBUTTON == wParam)
{
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
CCPoint pt(point.x/CC_CONTENT_SCALE_FACTOR(), point.y/CC_CONTENT_SCALE_FACTOR());
CCPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
if (m_obViewPortRect.equals(CCRectZero) || m_obViewPortRect.containsPoint(tmp))
{
m_bCaptured = true;
SetCapture(m_hWnd);
int id = 0;
pt.x *= m_windowTouchScaleX;
pt.y *= m_windowTouchScaleY;
handleTouchesBegin(1, &id, &pt.x, &pt.y);
}
}
break;
case WM_MOUSEMOVE:
if (MK_LBUTTON == wParam && m_bCaptured)
{
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
CCPoint pt(point.x/CC_CONTENT_SCALE_FACTOR(), point.y/CC_CONTENT_SCALE_FACTOR());
int id = 0;
pt.x *= m_windowTouchScaleX;
pt.y *= m_windowTouchScaleY;
handleTouchesMove(1, &id, &pt.x, &pt.y);
}
break;
case WM_LBUTTONUP:
if (m_bCaptured)
{
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
CCPoint pt(point.x/CC_CONTENT_SCALE_FACTOR(), point.y/CC_CONTENT_SCALE_FACTOR());
int id = 0;
pt.x *= m_windowTouchScaleX;
pt.y *= m_windowTouchScaleY;
handleTouchesEnd(1, &id, &pt.x, &pt.y);
ReleaseCapture();
m_bCaptured = false;
}
break;
case WM_SIZE:
switch (wParam)
{
case SIZE_RESTORED:
CCApplication::sharedApplication()->applicationWillEnterForeground();
break;
case SIZE_MINIMIZED:
CCApplication::sharedApplication()->applicationDidEnterBackground();
break;
}
break;
case WM_KEYDOWN:
if (wParam == VK_F1 || wParam == VK_F2)
{
CCDirector* pDirector = CCDirector::sharedDirector();
if (GetKeyState(VK_LSHIFT) < 0 || GetKeyState(VK_RSHIFT) < 0 || GetKeyState(VK_SHIFT) < 0)
pDirector->getKeypadDispatcher()->dispatchKeypadMSG(wParam == VK_F1 ? kTypeBackClicked : kTypeMenuClicked);
}
if ( m_lpfnAccelerometerKeyHook!=NULL )
{
(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
}
break;
case WM_KEYUP:
if ( m_lpfnAccelerometerKeyHook!=NULL )
{
(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
}
break;
case WM_CHAR:
{
if (wParam < 0x20)
{
if (VK_BACK == wParam)
{
CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
}
else if (VK_RETURN == wParam)
{
CCIMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1);
}
else if (VK_TAB == wParam)
{
// tab input
}
else if (VK_ESCAPE == wParam)
{
// ESC input
//CCDirector::sharedDirector()->end();
}
//.........这里部分代码省略.........