• 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
    
    
  • 相关阅读:
    python基础--字典
    python基础--字符串
    windows系统下安装python解释器和PyCharm
    promise
    node之events 模块,并通过实例化 EventEmitter 类来绑定和监听事件
    node.js之CommonJS
    head first 设计模式笔记9-迭代器模式
    Codeforces 1256B Minimize the Permutation
    Codeforces 1256B Minimize the Permutation
    CCF CSP 201809-4 再卖菜
  • 原文地址:https://www.cnblogs.com/yufenghou/p/4619527.html
Copyright © 2020-2023  润新知