int CCLuaEngine::executeLayerKeypadEvent(CCLayer* pLayer, int eventType) { CCScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptKeypadHandlerEntry(); if (!pScriptHandlerEntry) return 0; int nHandler = pScriptHandlerEntry->getHandler(); if (!nHandler) return 0; switch (eventType) { case kTypeBackClicked: m_stack->pushString("backClicked"); break; case kTypeMenuClicked: m_stack->pushString("menuClicked"); break; default: return 0; } int ret = m_stack->executeFunctionByHandler(nHandler, 1); m_stack->clean(); return ret; }
NS_CC_BEGIN // CCScriptHandlerEntry CCScriptHandlerEntry* CCScriptHandlerEntry::create(int nHandler) { CCScriptHandlerEntry* entry = new CCScriptHandlerEntry(nHandler); entry->autorelease(); return entry; }
int CCLuaEngine::executeAccelerometerEvent(CCLayer* pLayer, CCAcceleration* pAccelerationValue) { CCScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptAccelerateHandlerEntry(); int nHandler = pScriptHandlerEntry->getHandler(); if (!nHandler) return 0; m_stack->pushFloat(pAccelerationValue->x); m_stack->pushFloat(pAccelerationValue->y); m_stack->pushFloat(pAccelerationValue->z); m_stack->pushFloat(pAccelerationValue->timestamp); return m_stack->executeFunctionByHandler(nHandler, 4); }
NS_CC_BEGIN // #pragma mark - // #pragma mark CCScriptHandlerEntry // 脚本处理实体 CCScriptHandlerEntry* CCScriptHandlerEntry::create(int nHandler) { CCScriptHandlerEntry* entry = new CCScriptHandlerEntry(nHandler); entry->autorelease(); return entry; }
int CCLuaEngine::executeLayerKeypadEvent(CCLayer* pLayer, int eventType) { int ret = 0; do { CCScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptKeypadHandlerEntry(); CC_BREAK_IF(NULL == pScriptHandlerEntry); int nScriptHandler = pScriptHandlerEntry->getHandler(); CC_BREAK_IF(0 == nScriptHandler); cleanStack(); lua_newtable(m_state); lua_pushinteger(m_state, eventType); ret = executeFunctionByHandler(nScriptHandler, 1); } while (0); return ret; }
int CCLuaEngine::executeAccelerometerEvent(CCLayer* pLayer, CCAcceleration* pAccelerationValue) { int ret = 0; do { CCScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptAccelerateHandlerEntry(); CC_BREAK_IF(NULL == pScriptHandlerEntry); int nScriptHandler = pScriptHandlerEntry->getHandler(); CC_BREAK_IF(0 == nScriptHandler); cleanStack(); lua_newtable(m_state); lua_pushnumber(m_state, pAccelerationValue->x); lua_pushnumber(m_state, pAccelerationValue->y); lua_pushnumber(m_state, pAccelerationValue->z); lua_pushnumber(m_state, pAccelerationValue->timestamp); ret = executeFunctionByHandler(nScriptHandler, 4); } while (0); return ret; }
CCScriptHandlerEntry* CCScriptHandlerEntry::create ( KDint nHandler ) { CCScriptHandlerEntry* pEntry = new CCScriptHandlerEntry ( nHandler ); pEntry->autorelease ( ); return pEntry; }