Lua笔记:Button控件按钮创建及使用

来源:互联网 发布:c语言计算三角函数 编辑:程序博客网 时间:2024/06/05 08:03


    --------------------------- Button控件按钮使用 -------------------------------------------lua 中 Button按钮控件处理方式    --Button 触摸处理函数    local function TouchDownAction()    if self.simulateDataLayer:isVisible() then       print("Simulate Data is show")       self.simulateDataLayer:setVisible(false)    else       print("Simulate Data is not show")       self.simulateDataLayer:setVisible(true)    end    end    -- Button 按钮控件 添加模似数据所模块功能    local bgBtn = cc.Scale9Sprite:create("Shell_1.png")    local bgBtnHighLight = cc.Scale9Sprite:create("ball.png")    local titleBtnLabel = cc.Label:createWithSystemFont("SimulateData", "Marker Felt", 30)    titleBtnLabel:setColor(cc.c3b(159,168,175))        local controlButton = cc.ControlButton:create(titleBtnLabel, bgBtn)    controlButton:setBackgroundSpriteForState(bgBtnHighLight,cc.CONTROL_STATE_HIGH_LIGHTED)    controlButton:setTitleColorForState(cc.c3b(255, 255, 255), cc.CONTROL_STATE_HIGH_LIGHTED )    controlButton:setPosition(600,32)    --绑定事件    controlButton:registerControlEventHandler(TouchDownAction, cc.CONTROL_EVENTTYPE_TOUCH_DOWN)    cannonbg:addChild(controlButton)    --------------------------- Button控件按钮使用 -----------------------------------------


0 0
原创粉丝点击