int LuaEngine::executeLayerKeypadEvent(Layer* pLayer, int eventType) { ScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptKeypadHandlerEntry(); if (!pScriptHandlerEntry) return 0; int nHandler = pScriptHandlerEntry->getHandler(); if (!nHandler) return 0; switch (eventType) { case kTypeBackClicked: _stack->pushString("backClicked"); break; case kTypeMenuClicked: _stack->pushString("menuClicked"); break; default: return 0; } int ret = _stack->executeFunctionByHandler(nHandler, 1); _stack->clean(); return ret; }
NS_CC_BEGIN // // // ScriptHandlerEntry ScriptHandlerEntry* ScriptHandlerEntry::create(int handler) { ScriptHandlerEntry* entry = new (std::nothrow) ScriptHandlerEntry(handler); entry->autorelease(); return entry; }
NS_CC_BEGIN // #pragma mark - // #pragma mark ScriptHandlerEntry ScriptHandlerEntry* ScriptHandlerEntry::create(int nHandler) { ScriptHandlerEntry* entry = new ScriptHandlerEntry(nHandler); entry->autorelease(); return entry; }
int LuaEngine::executeAccelerometerEvent(Layer* pLayer, Acceleration* pAccelerationValue) { ScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptAccelerateHandlerEntry(); if (!pScriptHandlerEntry) return 0; int nHandler = pScriptHandlerEntry->getHandler(); if (!nHandler) return 0; _stack->pushFloat(pAccelerationValue->x); _stack->pushFloat(pAccelerationValue->y); _stack->pushFloat(pAccelerationValue->z); _stack->pushFloat(pAccelerationValue->timestamp); int ret = _stack->executeFunctionByHandler(nHandler, 4); _stack->clean(); return ret; }