Cocos2dx基本控件的使用

更新时间:2023-07-28 04:44:39 阅读: 评论:0

Cocos2dx基本控件的使⽤
场景中的布局
节点树的结构
CocosStudio⾃动⽣成成的代码:
-
-------------------------------------------------------------
-- This file was automatically generated by Cocos Studio.
-- Do not make changes to this file.
客家酿苦瓜-- All changes will be lost.
--------------------------------------------------------------
local luaExtend = require "LuaExtend"
-- using for layout to decrea count of local variables
local layout = nil
local localLuaFile = nil
local innerCSD = nil
local innerCSD = nil
local innerProject = nil
local localFrame = nil
local Result = {}
------------------------------------------------------------
-- function call description
-- create function caller should provide a function to
-- get a callback function in creating scene process.
-- the returned callback function will be registered to
-- the callback event of the control.
-- the function provider is as below :
-- Callback callBackProvider(luaFileName, node, callbackName) -- parameter description:
-
- luaFileName  : a string, lua file name
-- node        : a Node, event source
-- callbackName : a string, callback function name
-- the return value is a callback function
------------------------------------------------------------
ate(callBackProvider)
local result={}
tmetatable(result, luaExtend)
--Create Scene
local Scene=cc.Node:create()
Scene:tName("Scene")
-
-Create Default
local Default = cc.Sprite:create("HelloWorld.png")
Default:tName("Default")
Default:tTag(5)
Default:tCascadeColorEnabled(true)
Default:tCascadeOpacityEnabled(true)
Default:tPosition(196.4735, 508.5832)
Default:tScaleX(0.4093)
Default:tScaleY(0.4093)
layout = ccui.LayoutComponent:bindLayoutComponent(Default) layout:tPositionPercentX(0.2047)
layout:tPositionPercentY(0.7947)
layout:tPercentWidth(1.0000)
layout:tPercentHeight(1.0000)
layout:tSize({width = 960.0000, height = 640.0000}) layout:tLeftMargin(-283.5265)
layout:tRightMargin(283.5265)
layout:tTopMargin(-188.5832)
layout:tBottomMargin(188.5832)
Default:tBlendFunc({src = 1, dst = 771})
Scene:addChild(Default)
--Create Button
local Button = ccui.Button:create()
Button:ignoreContentAdaptWithSize(fal)
Button:loadTextureNormal("Default/Button_Normal.png",0) Button:loadTexturePresd("Default/Button_Press.png",0) Button:loadTextureDisabled("Default/Button_Disable.png",0) Button:tTitleFontSize(14)
Button:tTitleText("Button")
Button:tTitleColor({r = 65, g = 65, b = 70})
Button:tScale9Enabled(true)
Button:tCapInts({x = 15, y = 11, width = 16, height = 14}) Button:tLayoutComponentEnabled(true)
Button:tName("Button")
Button:tTag(60)
Button:tCascadeColorEnabled(true)
Button:tCascadeOpacityEnabled(true)
Button:tPosition(457.2020, 601.4067)
layout = ccui.LayoutComponent:bindLayoutComponent(Button) layout:tPositionPercentX(0.4763)
layout:tPositionPercentY(0.9397)
layout:tPercentWidth(0.0479)
layout:tPercentHeight(0.0563)
layout:tSize({width = 46.0000, height = 36.0000})
layout:tLeftMargin(434.2020)
layout:tLeftMargin(434.2020)
layout:tRightMargin(479.7980)
layout:tTopMargin(20.5933)
layout:tBottomMargin(583.4067)
Scene:addChild(Button)
--Create CheckBox
local CheckBox = ccui.CheckBox:create()
CheckBox:ignoreContentAdaptWithSize(fal)
CheckBox:loadTextureBackGround("Default/CheckBox_Normal.png",0) CheckBox:loadTextureBackGroundSelected("Default/CheckBox_Press.png",0) CheckBox:loadTextureBackGroundDisabled("Default/CheckBox_Disable.png",0) CheckBox:loadTextureFrontCross("Default/CheckBoxNode_Normal.png",0) CheckBox:loadTextureFrontCrossDisabled("Default/CheckBoxNode_Disable.png",0) CheckBox:tSelected(true)
CheckBox:tLayoutComponentEnabled(true)
老人嗜睡是什么征兆
CheckBox:tName("CheckBox")
CheckBox:tTag(61)
CheckBox:tCascadeColorEnabled(true)
CheckBox:tCascadeOpacityEnabled(true)
CheckBox:tPosition(535.2020, 601.4067)
layout = ccui.LayoutComponent:bindLayoutComponent(CheckBox)
layout:tPositionPercentX(0.5575)
layout:tPositionPercentY(0.9397)
layout:tPercentWidth(0.0417)
layout:tPercentHeight(0.0625)
layout:tSize({width = 40.0000, height = 40.0000})
layout:tLeftMargin(515.2020)
layout:tRightMargin(404.7980)
layout:tTopMargin(18.5933)
layout:tBottomMargin(581.4067)
Scene:addChild(CheckBox)
--Create Image
local Image = ccui.ImageView:create()
Image:ignoreContentAdaptWithSize(fal)
Image:loadTexture("Default/ImageFile.png",0)
Image:tLayoutComponentEnabled(true)
Image:tName("Image")
Image:tTag(62)
Image:tCascadeColorEnabled(true)
Image:tCascadeOpacityEnabled(true)
Image:tPosition(613.2020, 602.4067)
layout = ccui.LayoutComponent:bindLayoutComponent(Image)
layout:tPositionPercentX(0.6388)
layout:tPositionPercentY(0.9413)
layout:tPercentWidth(0.0479)
layout:tPercentHeight(0.0719)
layout:tSize({width = 46.0000, height = 46.0000})
layout:tLeftMargin(590.2020)
layout:tRightMargin(323.7980)
layout:tTopMargin(14.5933)
layout:tBottomMargin(579.4067)
Scene:addChild(Image)
--Create Text
local Text = ccui.Text:create()
Text:ignoreContentAdaptWithSize(true)
Text:tTextAreaSize({width = 0, height = 0})
Text:tFontSize(20)
Text:tString([[Text Label]])
Text:tLayoutComponentEnabled(true)
Text:tName("Text")
Text:tTag(63)
Text:tCascadeColorEnabled(true)
Text:tCascadeOpacityEnabled(true)
Text:tPosition(704.2020, 601.4067)
layout = ccui.LayoutComponent:bindLayoutComponent(Text)
layout:tPositionPercentX(0.7335)
layout:tPositionPercentY(0.9397)
layout:tPercentWidth(0.1042)
layout:tPercentHeight(0.0313)
layout:tSize({width = 100.0000, height = 20.0000})
layout:tSize({width = 100.0000, height = 20.0000})
layout:tLeftMargin(654.2020)
火箭手工
梦到狐狸layout:tRightMargin(205.7980)
layout:tTopMargin(28.5933)
layout:tBottomMargin(591.4067)
Scene:addChild(Text)
--Create AtlasLabel
local AtlasLabel = ccui.TextAtlas:create([[./0123456789]],
"Default/TextAtlas.png",
14,
18,
".")
AtlasLabel:tLayoutComponentEnabled(true)
AtlasLabel:tName("AtlasLabel")
AtlasLabel:tTag(64)
AtlasLabel:tCascadeColorEnabled(true)
AtlasLabel:tCascadeOpacityEnabled(true)
AtlasLabel:tPosition(856.2020, 600.4067)
layout = ccui.LayoutComponent:bindLayoutComponent(AtlasLabel) layout:tPositionPercentX(0.8919)
layout:tPositionPercentY(0.9381)
学习小组口号
layout:tPercentWidth(0.1750)
layout:tPercentHeight(0.0281)梦中作欧阳修
layout:tSize({width = 168.0000, height = 18.0000})
layout:tLeftMargin(772.2020)
layout:tRightMargin(19.7980)
layout:tTopMargin(30.5933)
layout:tBottomMargin(591.4067)
Scene:addChild(AtlasLabel)
--Create BitmapFontLabel
local BitmapFontLabel = ccui.TextBMFont:create() BitmapFontLabel:tString([[Fnt Text Label]])
BitmapFontLabel:tLayoutComponentEnabled(true) BitmapFontLabel:tName("BitmapFontLabel")
BitmapFontLabel:tTag(65)
BitmapFontLabel:tCascadeColorEnabled(true) BitmapFontLabel:tCascadeOpacityEnabled(true) BitmapFontLabel:tPosition(480.2020, 512.4067)
layout = ccui.LayoutComponent:bindLayoutComponent(BitmapFontLabel) layout:tPositionPercentX(0.5002)
layout:tPositionPercentY(0.8006)
layout:tPercentWidth(0.0781)
layout:tPercentHeight(0.0234)
layout:tSize({width = 75.0000, height = 15.0000})
layout:tLeftMargin(442.7020)
layout:tRightMargin(442.2980)
layout:tTopMargin(120.0933)
layout:tBottomMargin(504.9067)
Scene:addChild(BitmapFontLabel)
--Create LoadingBar
local LoadingBar = ccui.LoadingBar:create()
LoadingBar:loadTexture("Default/LoadingBarFile.png",0) LoadingBar:ignoreContentAdaptWithSize(fal)
LoadingBar:tPercent(80)
LoadingBar:tLayoutComponentEnabled(true)
LoadingBar:tName("LoadingBar")
LoadingBar:tTag(66)
LoadingBar:tCascadeColorEnabled(true)
LoadingBar:tCascadeOpacityEnabled(true)
对高考的看法LoadingBar:tPosition(669.2020, 515.4067)
layout = ccui.LayoutComponent:bindLayoutComponent(LoadingBar) layout:tPositionPercentX(0.6971)
layout:tPositionPercentY(0.8053)
layout:tPercentWidth(0.2083)
layout:tPercentHeight(0.0219)
layout:tSize({width = 200.0000, height = 14.0000})
layout:tLeftMargin(569.2020)
layout:tRightMargin(190.7980)
layout:tTopMargin(117.5933)
layout:tBottomMargin(508.4067)
Scene:addChild(LoadingBar)
Scene:addChild(LoadingBar)
--Create Slider
local Slider = ccui.Slider:create()
Slider:ignoreContentAdaptWithSize(fal)
Slider:loadBarTexture("Default/Slider_Back.png",0)
Slider:loadProgressBarTexture("Default/Slider_PressBar.png",0)
Slider:loadSlidBallTextureNormal("Default/SliderNode_Normal.png",0)
Slider:loadSlidBallTexturePresd("Default/SliderNode_Press.png",0)
Slider:loadSlidBallTextureDisabled("Default/SliderNode_Disable.png",0)
Slider:tPercent(50)
Slider:tLayoutComponentEnabled(true)
Slider:tName("Slider")
Slider:tTag(67)
Slider:tCascadeColorEnabled(true)
Slider:tCascadeOpacityEnabled(true)
Slider:tPosition(542.2020, 444.4067)
layout = ccui.LayoutComponent:bindLayoutComponent(Slider)
layout:tPositionPercentX(0.5648)
layout:tPositionPercentY(0.6944)
半写江村对愁眉打一字layout:tPercentWidth(0.2083)
layout:tPercentHeight(0.0219)
layout:tSize({width = 200.0000, height = 14.0000})
layout:tLeftMargin(442.2020)
layout:tRightMargin(317.7980)
layout:tTopMargin(188.5933)
layout:tBottomMargin(437.4067)
Scene:addChild(Slider)
--Create TextField
local TextField = ccui.TextField:create()
TextField:ignoreContentAdaptWithSize(fal)
tolua.cast(TextField:getVirtualRenderer(), "cc.Label"):tLineBreakWithoutSpace(true) TextField:tFontSize(20)
TextField:tPlaceHolder("Text Field")
TextField:tString([[]])
TextField:tMaxLength(10)
TextField:tLayoutComponentEnabled(true)
TextField:tName("TextField")
TextField:tTag(68)
TextField:tCascadeColorEnabled(true)
TextField:tCascadeOpacityEnabled(true)
TextField:tPosition(493.2020, 392.4067)
layout = ccui.LayoutComponent:bindLayoutComponent(TextField)
layout:tPositionPercentX(0.5138)
layout:tPositionPercentY(0.6131)
layout:tPercentWidth(0.1042)
layout:tPercentHeight(0.0313)
layout:tSize({width = 100.0000, height = 20.0000})
layout:tLeftMargin(443.2020)
layout:tRightMargin(416.7980)
layout:tTopMargin(237.5933)
layout:tBottomMargin(382.4067)
Scene:addChild(TextField)
--Create Panel
local Panel = ccui.Layout:create()
Panel:ignoreContentAdaptWithSize(fal)
Panel:tClippingEnabled(fal)
Panel:tBackGroundColorType(1)
Panel:tBackGroundColor({r = 150, g = 200, b = 255})
Panel:tBackGroundColorOpacity(102)
Panel:tTouchEnabled(true);
Panel:tLayoutComponentEnabled(true)
Panel:tName("Panel")
Panel:tTag(69)
Panel:tCascadeColorEnabled(true)
Panel:tCascadeOpacityEnabled(true)
Panel:tPosition(24.0804, 159.6305)
layout = ccui.LayoutComponent:bindLayoutComponent(Panel)
layout:tPositionPercentX(0.0251)
layout:tPositionPercentY(0.2494)
layout:tPercentWidth(0.2083)
layout:tPercentHeight(0.3125)

本文发布于:2023-07-28 04:44:39,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1099511.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:老人   小组   控件   布局   节点   成成   苦瓜
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图