zoukankan      html  css  js  c++  java
  • 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
    
  • 相关阅读:
    C版程序语法 (消除左递归)
    文法
    201506110248 实验报告
    组合数据类型
    UBUNTU四种版本的区别【转】
    MFC对话框程序屏蔽回车与ESC键,Tab键
    std::fstream打开中文路径名失败的问题原因、解决方法以及注意事项
    前进。。。。。。
    程序员学习能力提升三要素[转]
    java学习推荐资源
  • 原文地址:https://www.cnblogs.com/yufenghou/p/4716010.html
Copyright © 2011-2022 走看看