quick 截屏

MainScene



local MainScene = class("MainScene", function()
    return display.newScene("MainScene")
end)


local winSize = {width=display.width,height=display.height}
local fileName = "CaptureScreenTest.png"

function MainScene:ctor()

    self:addsp()


    local function afterCaptured(succeed, fileName)
        if succeed then
            --switch
            local PassScene=require("app.scenes.PassScene")
            local passScene=PassScene.new(fileName)
            cc.Director:getInstance():replaceScene(passScene)

        else
            cclog("Capture screen failed.")
        end
    end


    cc.ui.UIPushButton.new("test/BlueButton.png", {scale9 = true})
        :setButtonSize(200, 60)
        :setButtonLabel(cc.ui.UILabel.new({text = "share", size = 20}))
        :onButtonClicked(function(event)
            --caputre
            cc.utils:captureScreen(afterCaptured, fileName)
        end)
        :align(display.CENTER, display.cx , display.cy )
        :addTo(self)
end

function MainScene:addsp()
    --sp
    --var
    local left  = cc.p(winSize.width / 4, winSize.height / 2)
    local right = cc.p(winSize.width / 4 * 3, winSize.height / 2)

    --sp
    local sp1 = cc.Sprite:create("test/BlueButton.png")
    sp1:setPosition(left)

    --action
    local move1 = cc.MoveBy:create(1, cc.p(winSize.width/2, 0))
    local seq1  = cc.RepeatForever:create(cc.Sequence:create(move1, move1:reverse()))
    self:addChild(sp1)
    sp1:runAction(seq1)
end



return MainScene

PassScene


local PassScene = class("PassScene", function()
    return display.newScene("PassScene")
end)



function PassScene:ctor(outputFile)

    local sp = cc.Sprite:create(outputFile)
    sp:setPosition(display.cx,display.cy)
    self:addChild(sp)
    

    cc.ui.UILabel.new({
            UILabelType = 2, text = "PassScene", size = 64})
        :align(display.CENTER, display.cx, display.top-100)
        :addTo(self)
end



return PassScene

转载于:https://www.cnblogs.com/yufenghou/p/4619527.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值