Cocos2dx 3.X Lua check box usage ccui. CheckBox, cocos2dxlua

Source: Internet
Author: User

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
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.