Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FadeTransition ¶
type FadeTransition struct {
// contains filtered or unexported fields
}
A simple fade transition, that uses half the time to fade out of the current scene and half the time to fade into the new scene. You may wish to freeze inputs during the fade, which you can accomplish in the `ExitStart` and `EnterStart` phase of your scenes, and unfreeze during `EnterEnd` for the new scene.
func NewFadeTransition ¶
func NewFadeTransition(duration float64) *FadeTransition
Pass in the total duration (in seconds) to construct a new fade transition.
func (*FadeTransition) Interpolate ¶
func (self *FadeTransition) Interpolate(screen *ebiten.Image, src *ebiten.Image, dest *ebiten.Image)
func (*FadeTransition) Start ¶
func (self *FadeTransition) Start()
func (*FadeTransition) Update ¶
func (self *FadeTransition) Update() bool
type Scene ¶
type Scene[T any] interface { // Transition has started to enter your scene, load your stuff now EnterStart(state *T) // Transition has finished entering your scene, enable scene mechanics if they were disabled EnterEnd(state *T) Draw(state *T, screen *ebiten.Image) Update(state *T) error Layout(state *T, outsideWidth, outsideHeight int) (screenWidth, screenHeight int) // Transition has started to exit your scene, disable scene mechanics if you like ExitStart(state *T) // Transition has finished exiting your scene, wrap up now ExitEnd(state *T) }
Your should implement this on *YourScene, and T should be your global state across scenes. Your scene may have scene-local state as well.
type SceneManager ¶
type SceneManager[T any] struct { State *T // contains filtered or unexported fields }
The only field accessible here is State. The only use for this should be to implement custom transitions that also depend on the current state (for instance if you wish to show scores on the transition screen).
func NewSceneManager ¶
func NewSceneManager[T any](firstScene Scene[T], state *T) (manager *SceneManager[T])
Construct a new scene manager, given the initial scene and initial state.
func (*SceneManager[T]) Draw ¶
func (self *SceneManager[T]) Draw(screen *ebiten.Image)
func (*SceneManager[T]) Layout ¶
func (self *SceneManager[T]) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)
func (*SceneManager[T]) Transition ¶
func (self *SceneManager[T]) Transition(dest Scene[T], transition Transition) error
Call this to transition to a new scene.
func (*SceneManager[T]) Update ¶
func (self *SceneManager[T]) Update() error
type SimpleTransition ¶
type SimpleTransition struct { }
A simple transition that immediately transfers from the current state to the next
func (*SimpleTransition) Interpolate ¶
func (self *SimpleTransition) Interpolate(screen *ebiten.Image, src *ebiten.Image, dest *ebiten.Image)
func (*SimpleTransition) Start ¶
func (self *SimpleTransition) Start()
func (*SimpleTransition) Update ¶
func (self *SimpleTransition) Update() bool
type Transition ¶
type Transition interface { // Called before the transition begins. Initialize the state Start() // Interpolate between two images produced by the two scenes between whom this transition exists Interpolate(screen *ebiten.Image, src *ebiten.Image, dest *ebiten.Image) // Update the state of the transition and return whether the transition has finished Update() bool }