cocos2d-x  3.0
•All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LuaEngine Class Reference

#include <CCLuaEngine.h>

Inheritance diagram for LuaEngine:
ScriptEngineProtocol

Public Member Functions

virtual ~LuaEngine (void)
virtual ccScriptType getScriptType ()
 Get script type. More...
 
LuaStackgetLuaStack (void)
virtual void addSearchPath (const char *path)
 Add a path to find lua files in. More...
 
virtual void addLuaLoader (lua_CFunction func)
 Add lua loader, now it is used on android. More...
 
virtual int reload (const char *moduleFileName)
 reload script code contained in the given string. More...
 
virtual void removeScriptObjectByObject (Ref *object)
 Remove Object from lua state. More...
 
virtual void removeScriptHandler (int nHandler)
 Remove Lua function reference. More...
 
virtual int reallocateScriptHandler (int nHandler)
 Reallocate Lua function reference. More...
 
virtual int executeString (const char *codes)
 Execute script code contained in the given string. More...
 
virtual int executeScriptFile (const char *filename)
 Execute a script file. More...
 
virtual int executeGlobalFunction (const char *functionName)
 Execute a scripted global function. More...
 
virtual int executeNodeEvent (Node *pNode, int nAction)
virtual int executeMenuItemEvent (MenuItem *pMenuItem)
virtual int executeNotificationEvent (__NotificationCenter *pNotificationCenter, const char *pszName)
virtual int executeCallFuncActionEvent (CallFunc *pAction, Ref *pTarget=NULL)
virtual int executeSchedule (int nHandler, float dt, Node *pNode=NULL)
virtual int executeLayerTouchesEvent (Layer *pLayer, int eventType, __Set *pTouches)
virtual int executeLayerTouchEvent (Layer *pLayer, int eventType, Touch *pTouch)
virtual int executeLayerKeypadEvent (Layer *pLayer, int eventType)
virtual int executeAccelerometerEvent (Layer *pLayer, Acceleration *pAccelerationValue)
 execute a accelerometer event More...
 
virtual int executeEvent (int nHandler, const char *pEventName, Ref *pEventSource=NULL, const char *pEventSourceClassName=NULL)
virtual bool handleAssert (const char *msg)
 called by CCAssert to allow scripting engine to handle failed assertions More...
 
virtual bool parseConfig (ConfigType type, const std::string &str) override
 Parse configuration file. More...
 
virtual int sendEvent (ScriptEvent *message) override
 when trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be nullptr in lua More...
 
virtual int handleEvent (ScriptHandlerMgr::HandlerType type, void *data)
virtual int handleEvent (ScriptHandlerMgr::HandlerType type, void *data, int numResults, const std::function< void(lua_State *, int)> &func)
- Public Member Functions inherited from ScriptEngineProtocol
 ScriptEngineProtocol ()
virtual ~ScriptEngineProtocol ()
virtual void setCalledFromScript (bool callFromScript)
virtual bool isCalledFromScript ()

Static Public Member Functions

static LuaEnginegetInstance (void)
static CC_DEPRECATED_ATTRIBUTE
LuaEngine
defaultEngine (void)

Additional Inherited Members

- Public Types inherited from ScriptEngineProtocol
enum  ConfigType { NONE, COCOSTUDIO }
 

Constructor & Destructor Documentation

virtual ~LuaEngine ( void  )
virtual

Member Function Documentation

virtual void addLuaLoader ( lua_CFunction  func)
virtual

Add lua loader, now it is used on android.

virtual void addSearchPath ( const char *  path)
virtual

Add a path to find lua files in.

Parameters
pathto be added to the Lua path
static CC_DEPRECATED_ATTRIBUTE
LuaEngine* defaultEngine
( void  )
inlinestatic
virtual int
executeAccelerometerEvent
( Layer pLayer,
Acceleration pAccelerationValue 
)
virtual

execute a accelerometer event

virtual int
executeCallFuncActionEvent
( CallFunc pAction,
Ref pTarget = NULL 
)
virtual
virtual int executeEvent ( int  nHandler,
const char *  pEventName,
Ref pEventSource = NULL,
const char *  pEventSourceClassName = NULL 
)
virtual
virtual int executeGlobalFunction ( const char *  functionName)
virtual

Execute a scripted global function.

The function should not take any parameters and should return an integer.

Parameters
functionNameString object holding the name of the function, in the global script environment, that is to be executed.
Returns
The integer value returned from the script function.

Implements ScriptEngineProtocol.

virtual int executeLayerKeypadEvent ( Layer pLayer,
int  eventType 
)
virtual
virtual int
executeLayerTouchesEvent
( Layer pLayer,
int  eventType,
__Set pTouches 
)
virtual
virtual int executeLayerTouchEvent ( Layer pLayer,
int  eventType,
Touch pTouch 
)
virtual
virtual int executeMenuItemEvent ( MenuItem pMenuItem)
virtual
virtual int executeNodeEvent ( Node pNode,
int  nAction 
)
virtual
virtual int
executeNotificationEvent
( __NotificationCenter pNotificationCenter,
const char *  pszName 
)
virtual
virtual int executeSchedule ( int  nHandler,
float  dt,
Node pNode = NULL 
)
virtual
virtual int executeScriptFile ( const char *  filename)
virtual

Execute a script file.

Parameters
filenameString object holding the filename of the script file that is to be executed

Implements ScriptEngineProtocol.

virtual int executeString ( const char *  codes)
virtual

Execute script code contained in the given string.

Parameters
codesholding the valid script code that should be executed.
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.

Implements ScriptEngineProtocol.

static LuaEngine* getInstance ( void  )
static
LuaStack* getLuaStack ( void  )
inline
virtual ccScriptType getScriptType ( )
inlinevirtual

Get script type.

Reimplemented from ScriptEngineProtocol.

virtual bool handleAssert ( const char *  msg)
virtual

called by CCAssert to allow scripting engine to handle failed assertions

Returns
true if the assert was handled by the script engine, false otherwise.

Implements ScriptEngineProtocol.

virtual int handleEvent ( ScriptHandlerMgr::HandlerType  type,
void *  data 
)
virtual
virtual int handleEvent ( ScriptHandlerMgr::HandlerType  type,
void *  data,
int  numResults,
const std::function< void(lua_State *, int)> &  func 
)
virtual
virtual bool parseConfig ( ConfigType  type,
const std::string &  str 
)
overridevirtual

Parse configuration file.

Implements ScriptEngineProtocol.

virtual int reallocateScriptHandler ( int  nHandler)
virtual

Reallocate Lua function reference.

Reimplemented from ScriptEngineProtocol.

virtual int reload ( const char *  moduleFileName)
virtual

reload script code contained in the given string.

Parameters
moduleFileNameString object holding the filename of the script file that is to be executed
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.
virtual void removeScriptHandler ( int  nHandler)
virtual

Remove Lua function reference.

Reimplemented from ScriptEngineProtocol.

virtual void
removeScriptObjectByObject
( Ref object)
virtual

Remove Object from lua state.

Parameters
objectto remove

Implements ScriptEngineProtocol.

virtual int sendEvent ( ScriptEvent evt)
overridevirtual

when trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be nullptr in lua

Implements ScriptEngineProtocol.


The documentation for this class was generated from the following file: