added comments
This commit is contained in:
@@ -29,6 +29,7 @@ type Manager struct {
|
||||
scenes []Scene
|
||||
}
|
||||
|
||||
// can be used to create default manager instance
|
||||
func NewManager() Manager {
|
||||
return Manager{
|
||||
Info: GameInfo{
|
||||
@@ -42,6 +43,8 @@ func NewManager() Manager {
|
||||
}
|
||||
}
|
||||
|
||||
// ebitengine update proxy
|
||||
// manages scene transition and exists, then calls scene's update method
|
||||
func (m *Manager) Update() error {
|
||||
if m.currentScene == nil {
|
||||
return nil
|
||||
@@ -72,20 +75,24 @@ func (m *Manager) CheckTransitions() {
|
||||
}
|
||||
}
|
||||
|
||||
// calls current scene's draw method if the currentscene is valid
|
||||
func (m *Manager) Draw(screen *ebiten.Image) {
|
||||
if m.currentScene != nil {
|
||||
m.currentScene.Draw(screen)
|
||||
}
|
||||
}
|
||||
|
||||
// ebitengine proxy for layout
|
||||
func (m *Manager) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
|
||||
return m.Info.Dimension.Width, m.Info.Dimension.Height
|
||||
}
|
||||
|
||||
// appends scene to the managed scenes
|
||||
func (m *Manager) AddScene(s Scene) {
|
||||
m.scenes = append(m.scenes, s)
|
||||
}
|
||||
|
||||
// sets the current scene, based on sceneindex
|
||||
func (m *Manager) SetCurrentScene(sceneId int) {
|
||||
if sceneId >= 0 && sceneId < len(m.scenes) {
|
||||
m.currentSceneId = sceneId
|
||||
|
||||
Reference in New Issue
Block a user