• quick cocos 暂停场景


    local MainScene = class("MainScene", function()
        return display.newScene("MainScene")
    end)
    
    function MainScene:ctor()
        cc.ui.UIPushButton.new("test/BlueButton.png", {scale9 = true})
            :setButtonSize(160, 60)
            :setButtonLabel(cc.ui.UILabel.new({text = "Next", size = 32}))
            :onButtonClicked(function(event)
                    self:doPause()
                end)
            :align(display.CENTER, display.cx, display.cy)
            :addTo(self)
    end
    
    function MainScene:doPause()
    
        local renderTexture=cc.RenderTexture:create(display.width,display.height)
        renderTexture:begin()
        self:visit()
        renderTexture:endToLua()
    
        
        local GamePause=require("src.app.scenes.GamePause")
        local gamePause=GamePause.new(renderTexture)
        cc.Director:getInstance():pushScene(gamePause)
    end
    
    
    return MainScene
    
    
    local GamePause = class("GamePause", function()
        return display.newScene("GamePause")
    end)
    
    function GamePause:ctor(renderTexture)
    
        local sp=cc.Sprite:createWithTexture(renderTexture:getSprite():getTexture()):addTo(self)
        sp:setFlippedY(true)
        sp:setColor(cc.c3b(125,125,125))
        sp:setPosition(display.cx,display.cy)
    
    
        cc.ui.UIPushButton.new("test/BlueButton.png", {scale9 = true})
            :setButtonSize(160, 60)
            :setButtonLabel(cc.ui.UILabel.new({text = "back", size = 32}))
            :onButtonClicked(function(event)
                self:back()
            end)
            :align(display.CENTER, display.cx, display.cy+100)
            :addTo(self)
    
    end
    
    function GamePause:back()
        cc.Director:getInstance():popScene();
    end
    
    return GamePause
    
  • 相关阅读:
    【两周一本书】大话设计模式
    如何将在AWS上的网站快速从http转换为https
    java中error和exception的区别
    Java IO : NIO与IO的区别
    TCP/TP:DNS区域(Zone)
    Liferay 7:Liferay DXP解决方案
    Eclipse:Eclipse插件开发全套教程
    Liferay 7:Liferay DXP全套教程内附源码
    Liferay 7:Liferay内部博客地址
    Gradle:gradle下载插件
  • 原文地址:https://www.cnblogs.com/yufenghou/p/4716010.html
Copyright © 2020-2023  润新知