diff --git a/examples/aware/main.go b/examples/aware/main.go index 1124f38..01021cf 100644 --- a/examples/aware/main.go +++ b/examples/aware/main.go @@ -33,21 +33,21 @@ func (s *BaseScene) Layout(w, h int) (int, int) { return w, h } -func (s *BaseScene) Load(st State, sm *stagehand.SceneManager[State]) { +func (s *BaseScene) Load(st State, sm stagehand.SceneController[State]) { s.count = st - s.sm = sm + s.sm = sm.(*stagehand.SceneManager[State]) } func (s *BaseScene) Unload() State { return s.count } -func (s *BaseScene) PreTransition(toScene stagehand.Scene[State, *stagehand.SceneManager[State]]) State { +func (s *BaseScene) PreTransition(toScene stagehand.Scene[State]) State { s.count.OnTransition = true return s.count } -func (s *BaseScene) PostTransition(state State, fromScene stagehand.Scene[State, *stagehand.SceneManager[State]]) { +func (s *BaseScene) PostTransition(state State, fromScene stagehand.Scene[State]) { s.count.OnTransition = false } @@ -60,7 +60,7 @@ func (s *FirstScene) Update() error { s.count.Count++ } if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) { - s.sm.SwitchWithTransition(&SecondScene{}, stagehand.NewSlideTransition[State, *stagehand.SceneManager[State]](stagehand.TopToBottom, .05)) + s.sm.SwitchWithTransition(&SecondScene{}, stagehand.NewSlideTransition[State](stagehand.TopToBottom, .05)) } return nil } @@ -83,7 +83,7 @@ func (s *SecondScene) Update() error { s.count.Count-- } if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) { - s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewSlideTransition[State, *stagehand.SceneManager[State]](stagehand.BottomToTop, .05)) + s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewSlideTransition[State](stagehand.BottomToTop, .05)) } return nil } diff --git a/examples/director/main.go b/examples/director/main.go index 5ac0ac8..704ed7c 100644 --- a/examples/director/main.go +++ b/examples/director/main.go @@ -34,9 +34,9 @@ func (s *BaseScene) Layout(w, h int) (int, int) { return w, h } -func (s *BaseScene) Load(st State, sm *stagehand.SceneDirector[State]) { +func (s *BaseScene) Load(st State, sm stagehand.SceneController[State]) { s.count = st - s.sm = sm + s.sm = sm.(*stagehand.SceneDirector[State]) } func (s *BaseScene) Unload() State { @@ -90,12 +90,17 @@ func main() { s1 := &FirstScene{} s2 := &SecondScene{} - rs := map[stagehand.Scene[State, *stagehand.SceneDirector[State]]][]stagehand.Directive[State]{ + trans := stagehand.NewSlideTransition[State](stagehand.BottomToTop, 0.05) + rs := map[stagehand.Scene[State]][]stagehand.Directive[State]{ s1: []stagehand.Directive[State]{ stagehand.Directive[State]{Dest: s2, Trigger: Trigger}, }, s2: []stagehand.Directive[State]{ - stagehand.Directive[State]{Dest: s1, Trigger: Trigger}, + stagehand.Directive[State]{ + Dest: s1, + Trigger: Trigger, + Transition: trans, + }, }, } sm := stagehand.NewSceneDirector[State](s1, state, rs) diff --git a/examples/simple/main.go b/examples/simple/main.go index 7f3baf5..3ba9645 100644 --- a/examples/simple/main.go +++ b/examples/simple/main.go @@ -30,9 +30,9 @@ func (s *BaseScene) Layout(w, h int) (int, int) { return w, h } -func (s *BaseScene) Load(st State, sm *stagehand.SceneManager[State]) { +func (s *BaseScene) Load(st State, sm stagehand.SceneController[State]) { s.count = st - s.sm = sm + s.sm = sm.(*stagehand.SceneManager[State]) } func (s *BaseScene) Unload() State { @@ -67,7 +67,7 @@ func (s *SecondScene) Update() error { s.count-- } if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) { - s.sm.SwitchWithTransition(&ThirdScene{}, stagehand.NewFadeTransition[State, *stagehand.SceneManager[State]](.05)) + s.sm.SwitchWithTransition(&ThirdScene{}, stagehand.NewFadeTransition[State](.05)) } return nil } @@ -86,7 +86,7 @@ func (s *ThirdScene) Update() error { s.count *= 2 } if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) { - s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewSlideTransition[State, *stagehand.SceneManager[State]](stagehand.RightToLeft, .05)) + s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewSlideTransition[State](stagehand.RightToLeft, .05)) } return nil } diff --git a/examples/timed/main.go b/examples/timed/main.go index b43610f..41919fc 100644 --- a/examples/timed/main.go +++ b/examples/timed/main.go @@ -31,9 +31,9 @@ func (s *BaseScene) Layout(w, h int) (int, int) { return w, h } -func (s *BaseScene) Load(st State, sm *stagehand.SceneManager[State]) { +func (s *BaseScene) Load(st State, sm stagehand.SceneController[State]) { s.count = st - s.sm = sm + s.sm = sm.(*stagehand.SceneManager[State]) } func (s *BaseScene) Unload() State { @@ -49,7 +49,7 @@ func (s *FirstScene) Update() error { s.count++ } if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) { - s.sm.SwitchWithTransition(&SecondScene{}, stagehand.NewTicksTimedSlideTransition[State, *stagehand.SceneManager[State]](stagehand.LeftToRight, time.Second*time.Duration(s.count))) + s.sm.SwitchWithTransition(&SecondScene{}, stagehand.NewTicksTimedSlideTransition[State](stagehand.LeftToRight, time.Second*time.Duration(s.count))) } return nil } @@ -68,7 +68,7 @@ func (s *SecondScene) Update() error { s.count-- } if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) { - s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewDurationTimedSlideTransition[State, *stagehand.SceneManager[State]](stagehand.RightToLeft, time.Second*time.Duration(s.count))) + s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewDurationTimedSlideTransition[State](stagehand.RightToLeft, time.Second*time.Duration(s.count))) } return nil }