分辨率适配:
cc.Director:getInstance():setContentScaleFactor(640 / CONFIG_SCREEN_HEIGHT)
图标上下浮动:
local title = display.newSprite("img/title.png")
:pos(display.cx / 2 * 3, display.cy)
:addTo(self)
local move1 = cc.MoveBy:create(0.5, cc.p(0, 10))
local move2 = cc.MoveBy:create(0.5, cc.p(0, -10))
local SequenceAction = cc.Sequence:create( move1, move2 )
transition.execute(title, cc.RepeatForever:create( SequenceAction ))
添加按钮:
cc.ui.UIPushButton.new({ normal = "img/start1.png", pressed = "img/start2.png" })
:onButtonClicked(function()
print("start")
end)
:pos( display.cx / 2, display.cy )
:addTo(self)
同 onButtonClicked 方法类似的还有:
onButtonPressed(callback):用于监听按钮的按下事件
onButtonRelease(callback):用于监听按钮的释放事件
onButtonStateChanged(callback):用于监听按钮的状态改变事件