Fixed next scene setup when adding scene.
This commit is contained in:
18
manager.go
18
manager.go
@@ -17,9 +17,9 @@ type Area struct {
|
||||
}
|
||||
|
||||
type GameInfo struct {
|
||||
Name string
|
||||
Version string
|
||||
Dimension Area
|
||||
Name string
|
||||
Version string
|
||||
Dimensions Area
|
||||
}
|
||||
|
||||
type Manager struct {
|
||||
@@ -37,7 +37,7 @@ func NewManager() Manager {
|
||||
Info: GameInfo{
|
||||
Name: "groovy",
|
||||
Version: "1.0",
|
||||
Dimension: Area{
|
||||
Dimensions: Area{
|
||||
Width: defaultWidth,
|
||||
Height: defaultHeight,
|
||||
},
|
||||
@@ -70,12 +70,13 @@ func (m *Manager) Draw(screen *ebiten.Image) {
|
||||
|
||||
// ebitengine proxy for layout
|
||||
func (m *Manager) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
|
||||
return m.Info.Dimension.Width, m.Info.Dimension.Height
|
||||
return m.Info.Dimensions.Width, m.Info.Dimensions.Height
|
||||
}
|
||||
|
||||
// appends scene to the managed scenes
|
||||
func (m *Manager) AddScene(s Scene) {
|
||||
setDefaultHandlers(m, s)
|
||||
s.SetDimensions(m.Info.Dimensions)
|
||||
m.scenes = append(m.scenes, s)
|
||||
}
|
||||
|
||||
@@ -110,6 +111,7 @@ func (m *Manager) SetCurrentScene(sceneId uint) {
|
||||
}
|
||||
m.currentSceneId = sceneId
|
||||
m.currentScene = m.scenes[sceneId]
|
||||
m.nextSceneId = m.currentSceneId + 1
|
||||
}
|
||||
|
||||
// handle scene transition
|
||||
@@ -124,10 +126,14 @@ func (m *Manager) SetNextScene(sceneId uint) {
|
||||
|
||||
// sets sene dimensions
|
||||
func (m *Manager) SetDimensions(a Area) {
|
||||
m.Info.Dimension = a
|
||||
m.Info.Dimensions = a
|
||||
}
|
||||
|
||||
// report number of total scenes
|
||||
func (m *Manager) SceneCount() uint {
|
||||
return uint(len(m.scenes))
|
||||
}
|
||||
|
||||
func (m *Manager) GetScene(sceneId uint) Scene {
|
||||
return m.scenes[sceneId]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user