func (is *IntroState) buildScene() { am := is.assetManager // asset manager rootEntity := scenegraph.NewEntity(nil) rootEntity.W = gamecontext.GContext.MainSurface.W rootEntity.H = gamecontext.GContext.MainSurface.H titleEntity := scenegraph.NewEntity(am.Surfaces["titleText"]) mColor := is.fontNormalColor mHiColor := is.fontHighlightColor menuItems := []menu.Item{ {AssetFontID: "menuFont", Text: "Play!", Color: mColor, HiColor: mHiColor}, {AssetFontID: "menuFont", Text: "Quit", Color: mColor, HiColor: mHiColor}, } is.menu = menu.New(am, "introMenu", menuItems, 60, menu.MenuJustifyCenter) scenegraph.CenterEntityInParent(is.menu.RootEntity, rootEntity) is.menu.RootEntity.Y = 200 rootEntity.AddChild(titleEntity, is.menu.RootEntity) is.rootEntity = rootEntity // position title scenegraph.CenterEntityInSurface(titleEntity, gamecontext.GContext.MainSurface) titleEntity.Y = 40 }
// Construct the pause menu func (ps *PlayState) buildPauseMenu() { am := ps.assetManager // asset manager mainW := gamecontext.GContext.MainSurface.W mainH := gamecontext.GContext.MainSurface.H // Build pause menu shade background pauseBGSurface, err := util.MakeFillSurfaceAlpha(mainW, mainH, 0, 0, 0, 127) if err != nil { panic(fmt.Sprintf("Pause bgSurface: %v", err)) } ps.pauseMenuEntity = scenegraph.NewEntity(pauseBGSurface) ps.pauseMenuEntity.Visible = false // Build pause menu mColor := ps.fontNormalColor mHiColor := ps.fontHighlightColor menuItems := []menu.Item{ {AssetFontID: "menuFont", Text: "Return to Game", Color: mColor, HiColor: mHiColor}, {AssetFontID: "menuFont", Text: "Main Menu", Color: mColor, HiColor: mHiColor}, } ps.menu = menu.New(am, "playMenu", menuItems, 60, menu.MenuJustifyCenter) ps.menu.RootEntity.Y = 200 ps.pauseMenuEntity.AddChild(ps.menu.RootEntity) }