コード例 #1
0
 JNIEXPORT jboolean JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyDown(JNIEnv * env, jobject thiz, jint keyCode) {
     Director* pDirector = Director::getInstance();
     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;
 }
コード例 #2
0
ファイル: CCLayer.cpp プロジェクト: KIngpon/HXGame
/// Callbacks
void Layer::onEnter()
{
    Director* pDirector = Director::getInstance();
    // register 'parent' nodes first
    // since events are propagated in reverse order
    if (_touchEnabled)
    {
        this->registerWithTouchDispatcher();
    }

    // then iterate over all the children
    Node::onEnter();

    // add this layer to concern the Accelerometer Sensor
    if (_accelerometerEnabled)
    {
        pDirector->getAccelerometer()->setDelegate(CC_CALLBACK_1(Layer::didAccelerate, this));
    }

    // add this layer to concern the keypad msg
    if (_keypadEnabled)
    {
        pDirector->getKeypadDispatcher()->addDelegate(this);
    }
}
コード例 #3
0
ファイル: CCLayer.cpp プロジェクト: KIngpon/HXGame
/// isKeypadEnabled setter
void Layer::setKeypadEnabled(bool enabled)
{
    if (enabled != _keypadEnabled)
    {
        _keypadEnabled = enabled;

        if (_running)
        {
            Director* pDirector = Director::getInstance();
            if (enabled)
            {
                pDirector->getKeypadDispatcher()->addDelegate(this);
            }
            else
            {
                pDirector->getKeypadDispatcher()->removeDelegate(this);
            }
        }
    }
}
コード例 #4
0
ファイル: CCLayer.cpp プロジェクト: KIngpon/HXGame
void Layer::onExit()
{
    Director* pDirector = Director::getInstance();
    if( _touchEnabled )
    {
        pDirector->getTouchDispatcher()->removeDelegate(this);
    }

    // remove this layer from the delegates who concern Accelerometer Sensor
    if (_accelerometerEnabled)
    {
		pDirector->getAccelerometer()->setDelegate(nullptr);
    }

    // remove this layer from the delegates who concern the keypad msg
    if (_keypadEnabled)
    {
        pDirector->getKeypadDispatcher()->removeDelegate(this);
    }

    Node::onExit();
}