Difference between revisions of "SceneManager"
(→Events) |
|||
Line 121: | Line 121: | ||
=== Constants === | === Constants === | ||
− | SceneManager.moveFromRight<br/><!-- GIDEROSCST:SceneManager.moveFromRight--> | + | SceneManager.moveFromRight ''Move from the right'' <br/><!-- GIDEROSCST:SceneManager.moveFromRight Move from the right--> |
− | SceneManager.moveFromLeft<br/><!-- GIDEROSCST:SceneManager.moveFromLeft--> | + | SceneManager.moveFromLeft ''Move from the left'' <br/><!-- GIDEROSCST:SceneManager.moveFromLeft Move from the left--> |
− | SceneManager.moveFromBottom<br/><!-- GIDEROSCST:SceneManager.moveFromBottom--> | + | SceneManager.moveFromBottom ''Move from the bottom'' <br/><!-- GIDEROSCST:SceneManager.moveFromBottom Move from the bottom--> |
− | SceneManager.moveFromTop<br/><!-- GIDEROSCST:SceneManager.moveFromTop--> | + | SceneManager.moveFromTop ''Move from the top'' <br/><!-- GIDEROSCST:SceneManager.moveFromTop Move from the top--> |
− | SceneManager.moveFromRightWithFade<br/><!-- GIDEROSCST:SceneManager.moveFromRightWithFade--> | + | SceneManager.moveFromRightWithFade ''Move from the right with fading'' <br/><!-- GIDEROSCST:SceneManager.moveFromRightWithFade Move from the right with fading--> |
− | SceneManager.moveFromLeftWithFade<br/><!-- GIDEROSCST:SceneManager.moveFromLeftWithFade--> | + | SceneManager.moveFromLeftWithFade ''Move from the left with fading'' <br/><!-- GIDEROSCST:SceneManager.moveFromLeftWithFade Move from the left with fading--> |
− | SceneManager.moveFromBottomWithFade<br/><!-- GIDEROSCST:SceneManager.moveFromBottomWithFade--> | + | SceneManager.moveFromBottomWithFade ''Move from the bottom with fading'' <br/><!-- GIDEROSCST:SceneManager.moveFromBottomWithFade Move from the bottom with fading--> |
− | SceneManager.moveFromTopWithFade<br/><!-- GIDEROSCST:SceneManager.moveFromTopWithFade--> | + | SceneManager.moveFromTopWithFade ''Move from the top with fading'' <br/><!-- GIDEROSCST:SceneManager.moveFromTopWithFade Move from the top with fading--> |
− | SceneManager.overFromRight<br/><!-- GIDEROSCST:SceneManager.overFromRight--> | + | SceneManager.overFromRight ''Slide over from the right'' <br/><!-- GIDEROSCST:SceneManager.overFromRight Slide over from the right--> |
− | SceneManager.overFromLeft<br/><!-- GIDEROSCST:SceneManager.overFromLeft--> | + | SceneManager.overFromLeft ''Slide over from the left'' <br/><!-- GIDEROSCST:SceneManager.overFromLeft Slide over from the left--> |
− | SceneManager.overFromBottom<br/><!-- GIDEROSCST:SceneManager.overFromBottom--> | + | SceneManager.overFromBottom ''Slide over from the bottom'' <br/><!-- GIDEROSCST:SceneManager.overFromBottom Slide over from the bottom--> |
− | SceneManager.overFromTop<br/><!-- GIDEROSCST:SceneManager.overFromTop--> | + | SceneManager.overFromTop ''Slide over from the top'' <br/><!-- GIDEROSCST:SceneManager.overFromTop Slide over from the top--> |
− | SceneManager.overFromRightWithFade<br/><!-- GIDEROSCST:SceneManager.overFromRightWithFade--> | + | SceneManager.overFromRightWithFade ''Slide over from the right with fading'' <br/><!-- GIDEROSCST:SceneManager.overFromRightWithFade Slide over from the right with fading--> |
− | SceneManager.overFromLeftWithFade<br/><!-- GIDEROSCST:SceneManager.overFromLeftWithFade--> | + | SceneManager.overFromLeftWithFade ''Slide over from the left with fading'' <br/><!-- GIDEROSCST:SceneManager.overFromLeftWithFade Slide over from the left with fading--> |
− | SceneManager.overFromBottomWithFade<br/><!-- GIDEROSCST:SceneManager.overFromBottomWithFade--> | + | SceneManager.overFromBottomWithFade ''Slide over from the bottom with fading'' <br/><!-- GIDEROSCST:SceneManager.overFromBottomWithFade Slide over from the bottom with fading--> |
− | SceneManager.overFromTopWithFade<br/><!-- GIDEROSCST:SceneManager.overFromTopWithFade--> | + | SceneManager.overFromTopWithFade ''Slide over from the top with fading'' <br/><!-- GIDEROSCST:SceneManager.overFromTopWithFade Slide over from the top with fading--> |
− | SceneManager.fade<br/><!-- GIDEROSCST:SceneManager.fade--> | + | SceneManager.fade ''Fade over'' <br/><!-- GIDEROSCST:SceneManager.fade Fade over--> |
− | SceneManager.crossFade<br/><!-- GIDEROSCST:SceneManager.crossFade--> | + | SceneManager.crossFade ''Cross fade'' <br/><!-- GIDEROSCST:SceneManager.crossFade Cross fade--> |
− | SceneManager.flip<br/><!-- GIDEROSCST:SceneManager.flip--> | + | SceneManager.flip ''Flip'' <br/><!-- GIDEROSCST:SceneManager.flip Flip--> |
− | SceneManager.flipWithFade<br/><!-- GIDEROSCST:SceneManager.flipWithFade--> | + | SceneManager.flipWithFade ''Flip with fading'' <br/><!-- GIDEROSCST:SceneManager.flipWithFade Flip with fading--> |
− | SceneManager.flipWithShade<br/><!-- GIDEROSCST:SceneManager.flipWithShade--> | + | SceneManager.flipWithShade ''Flip with shading'' <br/><!-- GIDEROSCST:SceneManager.flipWithShade Flip with shading--> |
|} | |} | ||
{{GIDEROS IMPORTANT LINKS}} | {{GIDEROS IMPORTANT LINKS}} |
Revision as of 17:56, 7 January 2021
Supported platforms:
Available since: 2020.2
Inherits from: Sprite
Description
An easy way to manage scenes.
require "scenemanager"
Note: works in pair with the Easing plugin
Example
How to declare and change scenes
require "scenemanager"
require "easing"
scenemanager = SceneManager.new(
{
["menu"] = Menu,
["level01"] = Level01,
}
)
stage:addChild(scenemanager)
-- from app start to menu
scenemanager:changeScene("menu")
-- from menu to level01
--scenemanager:changeScene("level01", 1, SceneManager.moveFromRight, easing.outBack)
Below you will find what a scene class looks like.
The Bare Bone of a Scene Class
Level01 = Core.class(Sprite)
function Level01:init()
-- BG
application:setBackgroundColor(0x1234AA)
-- LISTENERS
self:addEventListener("enterBegin", self.onTransitionInBegin, self)
self:addEventListener("enterEnd", self.onTransitionInEnd, self)
self:addEventListener("exitBegin", self.onTransitionOutBegin, self)
self:addEventListener("exitEnd", self.onTransitionOutEnd, self)
end
-- GAME LOOP
function Level01:onEnterFrame(e)
end
-- EVENT LISTENERS
function Level01:onTransitionInBegin()
self:addEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
end
function Level01:onTransitionInEnd()
self:myKeysPressed()
end
function Level01:onTransitionOutBegin()
self:removeEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
end
function Level01:onTransitionOutEnd()
end
-- KEYS HANDLER
function Level01:myKeysPressed()
self:addEventListener(Event.KEY_DOWN, function(e)
-- for mobiles and desktops
if e.keyCode == KeyCode.BACK or e.keyCode == KeyCode.ESC then
scenemanager:changeScene("menu", 1, transitions[2], easing.outBack)
end
end)
end
A table of all transitions
transitions = {
SceneManager.moveFromRight, -- 1
SceneManager.moveFromLeft, -- 2
SceneManager.moveFromBottom, -- 3
SceneManager.moveFromTop, -- 4
SceneManager.moveFromRightWithFade, -- 5
SceneManager.moveFromLeftWithFade, -- 6
SceneManager.moveFromBottomWithFade, -- 7
SceneManager.moveFromTopWithFade, -- 8
SceneManager.overFromRight, -- 9
SceneManager.overFromLeft, -- 10
SceneManager.overFromBottom, -- 11
SceneManager.overFromTop, -- 12
SceneManager.overFromRightWithFade, -- 13
SceneManager.overFromLeftWithFade, -- 14
SceneManager.overFromBottomWithFade, -- 15
SceneManager.overFromTopWithFade, -- 16
SceneManager.fade, -- 17
SceneManager.crossFade, -- 18
SceneManager.flip, -- 19
SceneManager.flipWithFade, -- 20
SceneManager.flipWithShade, -- 21
}
MethodsSceneManager.new creates a new SceneManager object SceneManager:changeScene transitions to a scene |
Events"enterBegin" Scene is being entered ConstantsSceneManager.moveFromRight Move from the right |