Skip to content

Commit

Permalink
Adds fix to SwitchTo and misc
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Schutz committed May 28, 2024
1 parent 0269ac8 commit f35dfca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ func NewSceneManager[T any](scene Scene[T], state T) *SceneManager[T] {

// Scene Switching
func (s *SceneManager[T]) SwitchTo(scene Scene[T]) {
if prevTransition, ok := s.current.(SceneTransition[T]); ok {
// previous transition is still running, end it first
prevTransition.End()
}
if c, ok := s.current.(Scene[T]); ok {
scene.Load(c.Unload(), s)
s.current = scene
Expand Down
2 changes: 1 addition & 1 deletion transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (t *BaseTransition[T]) Layout(outsideWidth, outsideHeight int) (int, int) {

// Ends transition to the next scene
func (t *BaseTransition[T]) End() {
t.sm.ReturnFromTransition(t.toScene.(Scene[T]), t.fromScene.(Scene[T]))
t.sm.ReturnFromTransition(t.toScene, t.fromScene)
}

type FadeTransition[T any] struct {
Expand Down

0 comments on commit f35dfca

Please sign in to comment.