Fox router enables to switch scenes easily, and simplifies screen transitions.
To use Fox router, your top scene must be named app
, and it must have a child scene named scene
.
To allow your screens to be full screen:
app
andscene
can be 2ReferenceRect
- use
Layout mode: Uncontrolled
- use
Anchors preset: Full Rect
To illustrate scene
layout:
- Extend
router.gd
fromfox/core/router.gd
- Implement your
openXXX
by calling_openScene
extends 'res://fox/core/router.gd'
var home = preload("res://src/screens/home.tscn")
func openHome(options = {}):
call_deferred("_openScene", home, options)
Now you can call Router.openHome()
anywhere, for example from your app.gd/_ready()
function.
To handle passed options
and screen transitions, you can implement onOpen
in your screen:
example here in home.gd
:
func onOpen(options):
print('opened home with options', options)
calling openHome with options:
Router.openHome({plip='plop'})