组件:开机实现淡入淡出logo的功能
主场景
local MainScene = class("MainScene", function()
return display.newScene("MainScene")
end)
local scheduler = require(cc.PACKAGE_NAME .. ".scheduler")
function MainScene:onInterval()
local callback2 = cc.CallFunc:create(function()
print("replaceScene")
nextScene = require("app.scenes.LoginScene").new()
print(nextScene)
local transition = display.wrapSceneWithTransition(nextScene, "fade", 1.5)
--替换,释放mainscence
display.replaceScene(transition)
end)
local fadeOut =cc.FadeOut:create(1.5)
local action2 = cc.Sequence:create(fadeOut,callback2)
self.backgroundLayer:runAction(action2)
end
function MainScene:ctor()
self.backgroundLayer = display.newLayer()
self.backgroundLayer:addTo(self)
self.backgroundLayer:setCascadeOpacityEnabled(true)
local callback = cc.CallFunc:create(function()
print("callback")
print(self.bg)
local function callback()
self:onInterval()
end
scheduler.performWithDelayGlobal(callback, 1)
end)
local fadeIn =cc.FadeIn:create(2)
local action = cc.Sequence:create(fadeIn,callback)
--background
self.bg = display.newSprite("Bg/MainBg.png")
--设置透明度
:setOpacity(0)
:center()
:addTo(self.backgroundLayer)
self.bg:runAction(action)
self.author = display.newTTFLabel({text ="onley test",color = cc.c3b(255, 0, 0),size = 64})
:align(display.CENTER, display.cx,20)
self.author:addTo(self.backgroundLayer)
end
function MainScene:onEnter()
end
function MainScene:onExit()
print("exit")
end
return MainScene
登录场景
local LoginScene = class("LoginScene", function()
return display.newScene("LoginScene")
end)
function LoginScene:ctor()
end
function LoginScene:onEnter()
end
function LoginScene:onExit()
end
return LoginScene
|
请发表评论