Difference between revisions of "SceneManager"

From GiderosMobile
m (added one more example)
Line 3: Line 3:
 
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform pc.png]][[File:Platform mac.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
 
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform pc.png]][[File:Platform mac.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
 
'''<translate>Available since</translate>:''' 2020.2<br/>
 
'''<translate>Available since</translate>:''' 2020.2<br/>
 +
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Sprite|Sprite]]<br/>
  
 
=== Description ===
 
=== Description ===
An easy way to manage scenes.
+
An easy way to manage scenes.<br/>
 +
'''Note''': works in pair with the [[Easing]] plugin
 
<source lang="lua">
 
<source lang="lua">
 
require "scenemanager"
 
require "scenemanager"
Line 11: Line 13:
  
 
=== Example ===
 
=== Example ===
A table holding all scene transitions
 
<source lang="lua">
 
require "scenemanager"
 
-- 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
 
}
 
</source>
 
 
 
How to declare and change scenes
 
How to declare and change scenes
 
<source lang="lua">
 
<source lang="lua">
Line 51: Line 24:
 
}
 
}
 
)
 
)
 
 
stage:addChild(scenemanager)
 
stage:addChild(scenemanager)
 +
-- from app start to menu
 
scenemanager:changeScene("menu")
 
scenemanager:changeScene("menu")
 +
-- from menu to level1
 
--scenemanager:changeScene("level1", 1, SceneManager.moveFromRight, easing.outBack)
 
--scenemanager:changeScene("level1", 1, SceneManager.moveFromRight, easing.outBack)
 
</source>
 
</source>
Line 60: Line 34:
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Methods</translate> ===
 
=== <translate>Methods</translate> ===
 +
[[Special:MyLanguage/SceneManager.new|SceneManager.new]] ''<translate>creates a new SceneManager object</translate>''<br/><!-- GIDEROSMTD:SceneManager.new(table) creates a new SceneManager object -->
 +
 +
[[Special:MyLanguage/SceneManager:changeScene|SceneManager:changeScene]] ''<translate>transitions to a scene</translate>''<br/><!-- GIDEROSMTD:SceneManager:changeScene(scene, duration, transition, ease, options) transitions to a scene -->
 +
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Events</translate> ===
 
=== <translate>Events</translate> ===
 +
[[Special:MyLanguage/enterBegin|enterBegin]]<br/><!-- GIDEROSEVT:enterBegin-->
 +
[[Special:MyLanguage/enterBegin|enterEnd]]<br/><!-- GIDEROSEVT:enterEnd-->
 +
[[Special:MyLanguage/enterBegin|exitBegin]]<br/><!-- GIDEROSEVT:exitBegin-->
 +
[[Special:MyLanguage/enterBegin|exitEnd]]<br/><!-- GIDEROSEVT:exitEnd-->
 
=== <translate>Constants</translate> ===
 
=== <translate>Constants</translate> ===
 +
[[Special:MyLanguage/SceneManager.moveFromRight|SceneManager.moveFromRight]]<br/><!-- GIDEROSCST:SceneManager.moveFromRight-->
 +
[[Special:MyLanguage/SceneManager.moveFromLeft|SceneManager.moveFromLeft]]<br/><!-- GIDEROSCST:SceneManager.moveFromLeft-->
 +
[[Special:MyLanguage/SceneManager.moveFromBottom|SceneManager.moveFromBottom]]<br/><!-- GIDEROSCST:SceneManager.moveFromBottom-->
 +
[[Special:MyLanguage/SceneManager.moveFromTop|SceneManager.moveFromTop]]<br/><!-- GIDEROSCST:SceneManager.moveFromTop-->
 +
[[Special:MyLanguage/SceneManager.moveFromRightWithFade|SceneManager.moveFromRightWithFade]]<br/><!-- GIDEROSCST:SceneManager.moveFromRightWithFade-->
 +
[[Special:MyLanguage/SceneManager.moveFromLeftWithFade|SceneManager.moveFromLeftWithFade]]<br/><!-- GIDEROSCST:SceneManager.moveFromLeftWithFade-->
 +
[[Special:MyLanguage/SceneManager.moveFromBottomWithFade|SceneManager.moveFromBottomWithFade]]<br/><!-- GIDEROSCST:SceneManager.moveFromBottomWithFade-->
 +
[[Special:MyLanguage/SceneManager.moveFromTopWithFade|SceneManager.moveFromTopWithFade]]<br/><!-- GIDEROSCST:SceneManager.moveFromTopWithFade-->
 +
[[Special:MyLanguage/SceneManager.overFromRight|SceneManager.overFromRight]]<br/><!-- GIDEROSCST:SceneManager.overFromRight-->
 +
[[Special:MyLanguage/SceneManager.overFromLeft|SceneManager.overFromLeft]]<br/><!-- GIDEROSCST:SceneManager.overFromLeft-->
 +
[[Special:MyLanguage/SceneManager.overFromBottom|SceneManager.overFromBottom]]<br/><!-- GIDEROSCST:SceneManager.overFromBottom-->
 +
[[Special:MyLanguage/SceneManager.overFromTop|SceneManager.overFromTop]]<br/><!-- GIDEROSCST:SceneManager.overFromTop-->
 +
[[Special:MyLanguage/SceneManager.overFromRightWithFade|SceneManager.overFromRightWithFade]]<br/><!-- GIDEROSCST:SceneManager.overFromRightWithFade-->
 +
[[Special:MyLanguage/SceneManager.overFromLeftWithFade|SceneManager.overFromLeftWithFade]]<br/><!-- GIDEROSCST:SceneManager.overFromLeftWithFade-->
 +
[[Special:MyLanguage/SceneManager.overFromBottomWithFade|SceneManager.overFromBottomWithFade]]<br/><!-- GIDEROSCST:SceneManager.overFromBottomWithFade-->
 +
[[Special:MyLanguage/SceneManager.overFromTopWithFade|SceneManager.overFromTopWithFade]]<br/><!-- GIDEROSCST:SceneManager.overFromTopWithFade-->
 +
[[Special:MyLanguage/SceneManager.fade|SceneManager.fade]]<br/><!-- GIDEROSCST:SceneManager.fade-->
 +
[[Special:MyLanguage/SceneManager.crossFade|SceneManager.crossFade]]<br/><!-- GIDEROSCST:SceneManager.crossFade-->
 +
[[Special:MyLanguage/SceneManager.flip|SceneManager.flip]]<br/><!-- GIDEROSCST:SceneManager.flip-->
 +
[[Special:MyLanguage/SceneManager.flipWithFade|SceneManager.flipWithFade]]<br/><!-- GIDEROSCST:SceneManager.flipWithFade-->
 +
[[Special:MyLanguage/SceneManager.flipWithShade|SceneManager.flipWithShade]]<br/><!-- GIDEROSCST:SceneManager.flipWithShade-->
 
|}
 
|}
  
 
{{GIDEROS IMPORTANT LINKS}}
 
{{GIDEROS IMPORTANT LINKS}}

Revision as of 03:25, 26 March 2020

Supported platforms: Platform android.pngPlatform ios.pngPlatform pc.pngPlatform mac.pngPlatform winrt.pngPlatform win32.png
Available since: 2020.2
Inherits from: Sprite

Description

An easy way to manage scenes.
Note: works in pair with the Easing plugin

require "scenemanager"

Example

How to declare and change scenes

require "scenemanager"
require "easing"

scenemanager = SceneManager.new(
	{
		["menu"] = Menu,
		["level1"] = Level1,
	}
)
stage:addChild(scenemanager)
-- from app start to menu
scenemanager:changeScene("menu")
-- from menu to level1
--scenemanager:changeScene("level1", 1, SceneManager.moveFromRight, easing.outBack)

Methods

SceneManager.new creates a new SceneManager object

SceneManager:changeScene transitions to a scene

Events

enterBegin
enterEnd
exitBegin
exitEnd

Constants

SceneManager.moveFromRight
SceneManager.moveFromLeft
SceneManager.moveFromBottom
SceneManager.moveFromTop
SceneManager.moveFromRightWithFade
SceneManager.moveFromLeftWithFade
SceneManager.moveFromBottomWithFade
SceneManager.moveFromTopWithFade
SceneManager.overFromRight
SceneManager.overFromLeft
SceneManager.overFromBottom
SceneManager.overFromTop
SceneManager.overFromRightWithFade
SceneManager.overFromLeftWithFade
SceneManager.overFromBottomWithFade
SceneManager.overFromTopWithFade
SceneManager.fade
SceneManager.crossFade
SceneManager.flip
SceneManager.flipWithFade
SceneManager.flipWithShade