The first step: After the project group UI completes the UI control with Cocosstudio, there is a file with the suffix. Xml.ui in it, and double-clicking the file will open the UI.
Step two: Press CTRL + E to change the "sort style" to "Intelligent" and then export.
Step three: Copy the exported files to the Res directory of the project.
Fourth step: In the corresponding interface ctor function, add the following code (the author uses sublime Text 2)
Local layer = Touchgroup:create ()
Layer:addwidget (Guireader:sharereader (): Widgetfromjsonfile ("XXXXXXX. Exportjson "))
self:addchild (layer, 1000)
To run here, you can see a good UI layout.
-------------------------------------------------------Gorgeous split-line------------------------------------------------------------
Fifth Step: Add the following code below the above code:
SELF.MYBTN = Layer:getwidgetbyname (btnname)--btnname is Cocosstudio, after the control is selected, on the right side of the properties Bar-General, the name
--self.mybtn: Settouchenabled (True)--NOTE: This statement can be removed because the "interaction" property of the control is set in Cocosstudio.
Self.myBtn:addTouchEventListener (sender, event)--event is a touch type, 0,1,2,3 is began,moved,ended,canceled
if event = = 0 Then
--operation code
return false
end
end)
Note: Refer to http://www.cocoachina.com/bbs/read.php?tid=204622