cocos2d-lua3.7组件篇(一)-开机淡入淡出logo动画
【摘要】
组件:开机实现淡入淡出logo的功能
主场景
local MainScene = class("MainScene", function() return display.newScene("MainScene")end) local scheduler = ...
组件:开机实现淡入淡出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
文章来源: yujiang.blog.csdn.net,作者:鱼酱2333,版权归原作者所有,如需转载,请联系作者。
原文链接:yujiang.blog.csdn.net/article/details/78798821
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)