Documentation ¶
Index ¶
- func CalculateProgress(initialTime time.Time, duration time.Duration) float64
- func DurationToFactor(frequency float64, duration time.Duration) float64
- func MaxInt(a, b int) int
- func PreDraw[T any](bounds image.Rectangle, fromScene, toScene Scene[T]) (*ebiten.Image, *ebiten.Image)
- type BaseTransition
- type ClockInterface
- type Directive
- type FadeTransition
- type ProtoScene
- type RealClock
- type Scene
- type SceneController
- type SceneDirector
- type SceneManager
- func (s *SceneManager[T]) Draw(screen *ebiten.Image)
- func (s *SceneManager[T]) Layout(w, h int) (int, int)
- func (s *SceneManager[T]) ReturnFromTransition(scene, origin Scene[T])
- func (s *SceneManager[T]) SwitchTo(scene Scene[T])
- func (s *SceneManager[T]) SwitchWithTransition(scene Scene[T], transition SceneTransition[T])
- func (s *SceneManager[T]) Update() error
- type SceneTransition
- type SceneTransitionTrigger
- type SlideDirection
- type SlideTransition
- type TimedFadeTransition
- type TimedSlideTransition
- type TransitionAwareScene
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateProgress ¶ added in v1.1.0
Calculates the fraction of the duration that has passed since the initial time
func DurationToFactor ¶ added in v1.1.0
Converts a frequency(cycle/second) to a factor(change/cycle) for a given duration
Types ¶
type BaseTransition ¶
type BaseTransition[T any] struct { // contains filtered or unexported fields }
func (*BaseTransition[T]) Layout ¶
func (t *BaseTransition[T]) Layout(outsideWidth, outsideHeight int) (int, int)
Layout updates the layout of the scenes
func (*BaseTransition[T]) Start ¶
func (t *BaseTransition[T]) Start(fromScene, toScene Scene[T], sm SceneController[T])
func (*BaseTransition[T]) Update ¶
func (t *BaseTransition[T]) Update() error
Update updates the transition state
type ClockInterface ¶ added in v1.1.0
type ClockInterface interface { Since(time.Time) time.Duration Now() time.Time Until(time.Time) time.Duration Sleep(time.Duration) }
Clock helpers for mocking
var Clock ClockInterface = RealClock{}
type Directive ¶ added in v1.1.0
type Directive[T any] struct { Dest Scene[T] Transition SceneTransition[T] Trigger SceneTransitionTrigger }
A Directive is a struct that represents how a scene should be transitioned
type FadeTransition ¶
type FadeTransition[T any] struct { BaseTransition[T] // contains filtered or unexported fields }
func NewFadeTransition ¶
func NewFadeTransition[T any](factor float32) *FadeTransition[T]
func NewTicksTimedFadeTransition ¶ added in v1.1.0
func NewTicksTimedFadeTransition[T any](duration time.Duration) *FadeTransition[T]
func (*FadeTransition[T]) Draw ¶
func (t *FadeTransition[T]) Draw(screen *ebiten.Image)
Draw draws the transition effect
func (*FadeTransition[T]) Start ¶
func (t *FadeTransition[T]) Start(fromScene, toScene Scene[T], sm SceneController[T])
Start starts the transition from the given "from" scene to the given "to" scene
func (*FadeTransition[T]) Update ¶
func (t *FadeTransition[T]) Update() error
Update updates the transition state
type ProtoScene ¶ added in v1.1.0
type Scene ¶
type Scene[T any] interface { ProtoScene[T] Load(T, SceneController[T]) // Runs when scene is first started, must keep state and SceneManager Unload() T // Runs when scene is discarted, must return last state }
type SceneController ¶ added in v1.1.0
type SceneDirector ¶ added in v1.1.0
type SceneDirector[T any] struct { SceneManager[T] RuleSet map[Scene[T]][]Directive[T] }
A SceneDirector is a struct that manages the transitions between scenes
func NewSceneDirector ¶ added in v1.1.0
func NewSceneDirector[T any](scene Scene[T], state T, RuleSet map[Scene[T]][]Directive[T]) *SceneDirector[T]
func (*SceneDirector[T]) ProcessTrigger ¶ added in v1.1.0
func (d *SceneDirector[T]) ProcessTrigger(trigger SceneTransitionTrigger)
ProcessTrigger finds if a transition should be triggered
func (*SceneDirector[T]) ReturnFromTransition ¶ added in v1.1.0
func (d *SceneDirector[T]) ReturnFromTransition(scene, origin Scene[T])
type SceneManager ¶
type SceneManager[T any] struct { // contains filtered or unexported fields }
func NewSceneManager ¶
func NewSceneManager[T any](scene Scene[T], state T) *SceneManager[T]
func (*SceneManager[T]) Draw ¶
func (s *SceneManager[T]) Draw(screen *ebiten.Image)
func (*SceneManager[T]) ReturnFromTransition ¶ added in v1.1.0
func (s *SceneManager[T]) ReturnFromTransition(scene, origin Scene[T])
func (*SceneManager[T]) SwitchTo ¶
func (s *SceneManager[T]) SwitchTo(scene Scene[T])
Scene Switching
func (*SceneManager[T]) SwitchWithTransition ¶
func (s *SceneManager[T]) SwitchWithTransition(scene Scene[T], transition SceneTransition[T])
type SceneTransition ¶
type SceneTransition[T any] interface { ProtoScene[T] Start(fromScene, toScene Scene[T], sm SceneController[T]) End() }
type SceneTransitionTrigger ¶ added in v1.1.0
type SceneTransitionTrigger int
type SlideDirection ¶
type SlideDirection int
const ( LeftToRight SlideDirection = iota RightToLeft TopToBottom BottomToTop )
type SlideTransition ¶
type SlideTransition[T any] struct { BaseTransition[T] // contains filtered or unexported fields }
func NewSlideTransition ¶
func NewSlideTransition[T any](direction SlideDirection, factor float64) *SlideTransition[T]
func NewTicksTimedSlideTransition ¶ added in v1.1.0
func NewTicksTimedSlideTransition[T any](direction SlideDirection, duration time.Duration) *SlideTransition[T]
func (*SlideTransition[T]) Draw ¶
func (t *SlideTransition[T]) Draw(screen *ebiten.Image)
Draw draws the transition effect
func (*SlideTransition[T]) Start ¶
func (t *SlideTransition[T]) Start(fromScene Scene[T], toScene Scene[T], sm SceneController[T])
Start starts the transition from the given "from" scene to the given "to" scene
func (*SlideTransition[T]) Update ¶
func (t *SlideTransition[T]) Update() error
Update updates the transition state
type TimedFadeTransition ¶ added in v1.1.0
type TimedFadeTransition[T any] struct { FadeTransition[T] // contains filtered or unexported fields }
func NewDurationTimedFadeTransition ¶ added in v1.1.0
func NewDurationTimedFadeTransition[T any](duration time.Duration) *TimedFadeTransition[T]
func (*TimedFadeTransition[T]) Start ¶ added in v1.1.0
func (t *TimedFadeTransition[T]) Start(fromScene, toScene Scene[T], sm SceneController[T])
func (*TimedFadeTransition[T]) Update ¶ added in v1.1.0
func (t *TimedFadeTransition[T]) Update() error
type TimedSlideTransition ¶ added in v1.1.0
type TimedSlideTransition[T any] struct { SlideTransition[T] // contains filtered or unexported fields }
func NewDurationTimedSlideTransition ¶ added in v1.1.0
func NewDurationTimedSlideTransition[T any](direction SlideDirection, duration time.Duration) *TimedSlideTransition[T]
func (*TimedSlideTransition[T]) Start ¶ added in v1.1.0
func (t *TimedSlideTransition[T]) Start(fromScene, toScene Scene[T], sm SceneController[T])
func (*TimedSlideTransition[T]) Update ¶ added in v1.1.0
func (t *TimedSlideTransition[T]) Update() error