Cocos2dX-lua Commonly used functions

一些常用的函数,写出来主要是方便拷贝哈哈哈哈哈哈哈……

setPosition //设置坐标 setPosition(cc.p(x,y))
setAnchorPoint //设置锚点 setAnchorPoint(cc.p(0,0))
setContentSize //设置大小 setContentSize(cc.size(width, height))
setLocalZOrder //设置层级 setLocalZOrder(0)
setScale //设置缩放 (0-1)setScale(0.5)
setRotationSkewY //翻转 setRotationSkewY(180)
setFlippedX //镜像反转 setFlippedX(true)
setRotation //旋转 setRotation(90)
removeFromParent //从父物体上移除 removeFromParent()
removeAllChildren //移除所有子物体 removeAllChildren()
setOpacity //设置透明度(0-255)setOpacity(150)
setColor //设置颜色 setColor(cc.c3b(128, 128, 128)) 支持c4b
setTouchEnabled //是否可点 setTouchEnabled(true)
setVisible //是否可见 setVisible(true) 我习惯用show和hide
stopAllActions //停止所有Action stopAllActions()
getChildByTag //根据tag找控件 getChildByTag(99)
getChildByName //根据名字找控件 getChildByName(“login_btn”)

有set方法一般都会有get方法,所以不写两次

string.upper(argument) –字符串全部转为大写字母
string.lower(argument) –字符串全部转为小写字母
string.format(…) –格式化字符串(拼接)
string.len(arg) –计算字符串长度

local chips3 = math.max(unpack(rewards)) –求数组rewards中的最大值

performWithDelay(self,function ( … ) –延时调用

end,1.2)

Leave a Reply

Your email address will not be published. Required fields are marked *