diff --git a/manager.go b/manager.go index da1912f..f6df33e 100644 --- a/manager.go +++ b/manager.go @@ -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 diff --git a/transition.go b/transition.go index 01181ff..8ff2abc 100644 --- a/transition.go +++ b/transition.go @@ -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 {