2011-06-21 15:50:47 +08:00
|
|
|
/****************************************************************************
|
2011-06-21 16:12:07 +08:00
|
|
|
Copyright (c) 2011 cocos2d-x.org
|
2011-06-21 15:50:47 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
2011-06-20 17:31:38 +08:00
|
|
|
#include "LuaEngine.h"
|
2011-06-21 10:18:43 +08:00
|
|
|
#include "LuaEngineImpl.h"
|
2011-06-20 17:31:38 +08:00
|
|
|
|
|
|
|
using namespace cocos2d;
|
|
|
|
|
|
|
|
// functions for excute touch event
|
2011-06-21 10:18:43 +08:00
|
|
|
bool LuaEngine::executeTouchEvent(const char *pszFuncName, CCTouch *pTouch)
|
2011-06-20 17:31:38 +08:00
|
|
|
{
|
|
|
|
return CCLuaScriptModule::sharedLuaScriptModule()->executeTouch(pszFuncName, pTouch);
|
|
|
|
}
|
|
|
|
|
2011-06-21 10:18:43 +08:00
|
|
|
bool LuaEngine::executeTouchesEvent(const char *pszFuncName, CCSet *pTouches)
|
2011-06-20 17:31:38 +08:00
|
|
|
{
|
|
|
|
return CCLuaScriptModule::sharedLuaScriptModule()->executeTouchesEvent(pszFuncName, pTouches);
|
|
|
|
}
|
|
|
|
|
|
|
|
// functions for CCCallFuncX
|
2011-06-21 10:18:43 +08:00
|
|
|
bool LuaEngine::executeCallFunc(const char *pszFuncName)
|
2011-06-20 17:31:38 +08:00
|
|
|
{
|
|
|
|
return CCLuaScriptModule::sharedLuaScriptModule()->executeCallFunc(pszFuncName);
|
|
|
|
}
|
|
|
|
|
2011-06-21 10:18:43 +08:00
|
|
|
bool LuaEngine::executeCallFuncN(const char *pszFuncName, CCNode *pNode)
|
2011-06-20 17:31:38 +08:00
|
|
|
{
|
|
|
|
return CCLuaScriptModule::sharedLuaScriptModule()->executeCallFuncN(pszFuncName, pNode);
|
|
|
|
}
|
|
|
|
|
2011-06-21 10:18:43 +08:00
|
|
|
bool LuaEngine::executeCallFuncND(const char *pszFuncName, CCNode *pNode, void *pData)
|
2011-06-20 17:31:38 +08:00
|
|
|
{
|
|
|
|
return CCLuaScriptModule::sharedLuaScriptModule()->executeCallFuncND(pszFuncName, pNode, pData);
|
|
|
|
}
|
|
|
|
|
2011-06-21 10:18:43 +08:00
|
|
|
bool LuaEngine::executeCallFunc0(const char *pszFuncName, CCObject *pObject)
|
2011-06-20 17:31:38 +08:00
|
|
|
{
|
|
|
|
// use executeCallFuncN() to implement it
|
|
|
|
return CCLuaScriptModule::sharedLuaScriptModule()->executeCallFuncO(pszFuncName, pObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
// excute a script function without params
|
2011-06-21 11:47:57 +08:00
|
|
|
int LuaEngine::executeFuction(const char *pszFuncName)
|
2011-06-20 17:31:38 +08:00
|
|
|
{
|
|
|
|
return CCLuaScriptModule::sharedLuaScriptModule()->executeScriptGlobal(pszFuncName);
|
|
|
|
}
|
|
|
|
|
|
|
|
// excute a script file
|
2011-06-21 10:18:43 +08:00
|
|
|
bool LuaEngine::executeScriptFile(const char* pszFileName)
|
2011-06-20 17:31:38 +08:00
|
|
|
{
|
|
|
|
return CCLuaScriptModule::sharedLuaScriptModule()->executeScriptFile(pszFileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
// excute script from string
|
2011-06-21 10:18:43 +08:00
|
|
|
bool LuaEngine::executeString(const char* pszCodes)
|
2011-06-20 17:31:38 +08:00
|
|
|
{
|
|
|
|
return CCLuaScriptModule::sharedLuaScriptModule()->executeString(pszCodes);
|
|
|
|
}
|
2011-06-21 11:47:57 +08:00
|
|
|
|
|
|
|
bool LuaEngine::executeSchedule(const char* pszFuncName, ccTime t)
|
|
|
|
{
|
|
|
|
return CCLuaScriptModule::sharedLuaScriptModule()->executeSchedule(pszFuncName, t);
|
|
|
|
}
|