Cocos2dx 3.X Lua check box usage ccui. CheckBox, cocos2dxlua
The image resources used in this article are in the official test. You can search for the file name in the cocos2dx engine to find the resource.
You need to write the function in front of it. Otherwise, the function cannot be found later. In lua, the system prompts that the function is nil ....
-- Response to event Functions
Local function selectedEvent (sender, eventType)
If eventType = ccui. CheckBoxEventType. selected then
Cclog ("eventType = ccui. CheckBoxEventType. selected ")
Elseif eventType = ccui. CheckBoxEventType. unselected then
Cclog ("ccui. CheckBoxEventType. unselected ")
End
End
-- Create check box
Local checkBox = ccui. CheckBox: create ()
CheckBox: setTouchEnabled (true)
CheckBox: loadTextures ("check_box_normal.png ",
"Check_box_normal_press.png ",
"Check_box_active.png ",
"Check_box_normal_disable.png ",
"Check_box_active_disable.png ")
CheckBox: setPosition (cc. p (120,300) -- coordinate
CheckBox: addEventListenerCheckBox (selectedEvent) -- register the event layerFarm: addChild (checkBox, 10) -- add to Layer
When cocos2dx is developed in vs2012 and lua is called, an error is returned.
Check whether the path of luaXML. lua LuaXML_lib.lua is the same as that of require ("luaXML"). The error message is that the file cannot be found!
Kneeling Cocos2dx/lua learning materials hope you can recommend more
Lua information is really not much in fact there is nothing to learn, the main or familiar with the syntax, the other is to call the Cocos2d-x inside the thing