--图片local image = ccui.ImageView:create()image:loadTexture("ui/bg.png") --直接获取图片--image:loadTexture("bg.png",ccui.TextureResType.plistType) --从plist中获取--按钮local button = ccui.Button:create()button:loadTextures("bg.png","bgd.png","",ccui.TextureResType.plistType)--文本local text = ccui.Text:create()text:setString("hello")text:setFontSize()--输入框local input = ccui.TextField:create()input:setText("name")input:setPlaceHolder("请输入") --只要输入,就会替换当前文字input:setMaxLengthEnabled(true)input:setMaxLength()input:setTouchEnabled(true)local value = input:getStringValue()--标签文本local text = ccui.TextAtlas:create()text:setProperty("5","UI/number.png",,,"0")--动画local frame1 = cc.SpriteFrameCache:getInstance():getSpriteFrame(".png") --默认从缓存里读取local frame2 = cc.SpriteFrameCache:getInstance():getSpriteFrame(".png")local frame3 = cc.SpriteFrameCache:getInstance():getSpriteFrame(".png")local frames = {frame1,frame2,frame3}local animation = cc.Animation:createWithSpriteFrames(frames,0.1)--每帧间隔0.1秒local animate = cc.Animate:create(animation)local sprite = cc.Sprite:createWithSpriteFrameName(".png")sprite:runAction(animate)--移动local move = cc.MoveTo:create(0.2,cc.p(,))local move = cc.MoveBy:create(0.2,cc.p(,))dog:runAction(move)--缩放local scale = cc.ScaleTo:create(0.2,0.9)local scale = cc.ScaleBy:create(0.2,1.5)bird:runAction(scale)--旋转local rotate = cc.RotateTo:create(0.2,)local rotate = cc.RotateBy:create(0.2,-)bird:runAction(rotate)--跳跃local jump = cc.JumpTo:create(2,ccp(,),,4) --时间,目标位置,跳跃高度,跳跃次数local jump = cc.JumpBy:create(2,ccp(,),,4)sprite:runAction(jump)--贝塞尔曲线local data = {cc.p(,),--起点cc.p(,),--控制点cc.p(,)--终点}local bezier = cc.BezierTo:create(3, data)local bezier = cc.BezierBy:create(3, data)sprite:runAction(bezier)--顺序self:runAction(cc.Sequence:create(cc.DelayTime:create(0.3), cc.CallFunc:create(function( )printInfo("")end)))image:runAction(cc.Sequence:create(move, cc.CallFunc:create(function( )printInfo("")end)))--重复image:runAction(cc.RepeatForever:create(sequence))--重复动作MoveBy有reverse()方法MoveTo没有sowrd2:runAction(cc.Repeat:create(cc.Sequence:create(rotate2,rotate2:reverse()), 1))--按钮监听local onClick = function ( sender, eventType )if eventType == ccui.TouchEventType.ended thenif sender == self.m_btn thenprintInfo("")endendself.m_btn:addTouchEventListener(onClick)end--每隔时间执行一次local function listet( ... )if self.m_schedulerHander then--停止scheduler.unscheduleGlobal(self.m_schedulerHander)self.m_schedulerHander = nil endendself.m_schedulerHander = scheduler.scheduleGlobal(listet,0.2)
推荐整理分享cocos2dx-3.2+lua 常用代码,希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!
如何为listview的每项中edittext控件添加textwacher listview中的每项都有一个edittext,而且现在需要实时监听该edittext的输入,在listview的外部进行改变(例如用户修改单价,外部的总价需要变化)添加监听
魅族-魅蓝note无法链接adb解决办法 在mac终端执行:$echo0x2a~/.android/adb_usb.ini$adbkill-server$adbdevices第一行解释:直接把adb_usb.ini里面的内容清空,然后把0x2a写在adb_usb.ini里面第二行不执行
java多线程死锁 原文链接作者:JakobJenkov译者:申章校对:丁一java中死锁是两个或更多线程阻塞着等待其它处于死锁状态的线程所持有的锁。死锁通常发生在多个线程