It’s all basicCocos2dConstants.lua
In the file, I feel that it is more convenient and intuitive to use than the C + + version
frameworks/cocos2d-x/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua
cc.PLATFORM_OS_WINDOWS = 0
cc.PLATFORM_OS_LINUX = 1
cc.PLATFORM_OS_MAC = 2
cc.PLATFORM_OS_ANDROID = 3
cc.PLATFORM_OS_IPHONE = 4
cc.PLATFORM_OS_IPAD = 5
cc.PLATFORM_OS_BLACKBERRY = 6
cc.PLATFORM_OS_NACL = 7
cc.PLATFORM_OS_EMSCRIPTEN = 8
cc.PLATFORM_OS_TIZEN = 9
cc.LANGUAGE_ENGLISH = 0
cc.LANGUAGE_CHINESE = 1
cc.LANGUAGE_FRENCH = 2
cc.LANGUAGE_ITALIAN = 3
cc.LANGUAGE_GERMAN = 4
cc.LANGUAGE_SPANISH = 5
cc.LANGUAGE_RUSSIAN = 6
cc.LANGUAGE_KOREAN = 7
cc.LANGUAGE_JAPANESE = 8
cc.LANGUAGE_HUNGARIAN = 9
cc.LANGUAGE_PORTUGUESE = 10
cc.LANGUAGE_ARABIC = 11
cc.EVENT_UNKNOWN = 0
cc.EVENT_TOUCH_ONE_BY_ONE = 1
cc.EVENT_TOUCH_ALL_AT_ONCE = 2
cc.EVENT_KEYBOARD = 3
cc.EVENT_MOUSE = 4
cc.EVENT_ACCELERATION = 5
cc.EVENT_CUSTOM = 6
In the frameworks / cocos2d-x / cocos / scripting / Lua binding / script / directory, there are many other. Lua files that have well-defined APIs, which are worth looking at and have a clear idea. For example, in thecocos2d.lua
The method of quickly generating point object defined incc.p()
The related methods were as follows
--Point
function cc.p(_x,_y)
if nil == _y then
return { x = _x.x, y = _x.y }
else
return { x = _x, y = _y }
end
end
function cc.pAdd(pt1,pt2)
return {x = pt1.x + pt2.x , y = pt1.y + pt2.y }
end
Another example isjson.lua
Mediumencode
anddecode
MethodsAudioEngine.lua
The global variables defined in can be used directlyAudioEngine
Lua, these functions are easy to use, it is worth to see the use of these files.