title now displayed

This commit is contained in:
Harrison Deng 2018-11-15 01:22:35 -06:00
parent 507cde744d
commit 8377bb5ae8
4 changed files with 31 additions and 11 deletions

View File

@ -30,7 +30,7 @@ namespace RhythmBullet
readonly ResolutionContentResolver resolutionContentResolver;
public PreferencesManager preferencesManager;
private ScreenManager screenManager;
private Camera2D camera;
public Camera2D Camera { get; private set; }
private bool resizing;
public RhythmBulletGame()
@ -75,8 +75,8 @@ namespace RhythmBullet
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
camera = new Camera2D(graphics.GraphicsDevice);
screenManager = new ScreenManager(graphics, camera);
Camera = new Camera2D(graphics.GraphicsDevice);
screenManager = new ScreenManager(graphics, Camera);
screenManager.RequireNextScreenEvent += ExitTransitionComplete;
QueueContent();
screenManager.Screen = new LoadingScreen(Content.Load<Texture2D>("RhythmBullet"), 0.7f);
@ -111,7 +111,7 @@ namespace RhythmBullet
screenManager.UpdateCurrentScreen(gameTime, Assets.Done);
InputUtilities.Update();
camera.Update();
Camera.Update();
base.Update(gameTime);
}

View File

@ -2,20 +2,29 @@
using Microsoft.Xna.Framework.Graphics;
using RhythmBullet.Zer01HD.UI.Book;
using RhythmBullet.Zer01HD.Utilities.ContentSystem;
using RhythmBullet.Zer01HD.Utilities.UI.Modular.Modules;
namespace RhythmBullet.Zer01HD.Game.Screens.MainMenu
{
internal class MainPage : Page
{
Texture2D title;
internal MainPage(ContentSystem assets, GraphicsDevice graphicsDevice) : base(0, 0, graphicsDevice)
Image title;
internal MainPage(ContentSystem assets) : base(0, 0)
{
title = assets.Get<Texture2D>("title");
title = new Image(assets.Get<Texture2D>("title"));
AddModule(title);
}
public override void ApplySize(int width, int height)
{
title.Scale = (width - 40) / title.Texture.Width;
title.Bounds.X = (int)((width - title.Bounds.Width) / 2f);
title.Bounds.Y = (int)((height - title.Bounds.Height) / 2f);
base.ApplySize(width, height);
}
public override void Draw(SpriteBatch batch)
{
batch.Draw(title, title.Bounds, Color.White);
base.Draw(batch);
}
}

View File

@ -12,6 +12,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RhythmBullet.Zer01HD.UI.Book;
using RhythmBullet.Zer01HD.Utilities.Camera;
namespace RhythmBullet.Zer01HD.Game.Screens.MainMenu
{
@ -20,12 +21,21 @@ namespace RhythmBullet.Zer01HD.Game.Screens.MainMenu
FadeAwayTransition fat;
Texture2D background;
Book book;
MainPage mainPage;
public MainScreen(ContentSystem assets) : base(true)
{
background = assets.Get<Texture2D>("backgrounds/mainBG");
fat = new FadeAwayTransition(1.5f);
book = new Book(Camera);
}
book = new Book();
mainPage = new MainPage(assets);
book.AddPages(mainPage);
}
public override void Initiate(GraphicsDevice graphicsDevice, Rectangle screenSize, Camera2D camera)
{
book.Initiate(camera, screenSize);
base.Initiate(graphicsDevice, screenSize, camera);
}
public override void Show()
{
@ -35,6 +45,7 @@ namespace RhythmBullet.Zer01HD.Game.Screens.MainMenu
public override void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(background, ScreenSize, Color.White);
book.Draw(spriteBatch);
base.Draw(spriteBatch);

View File

@ -22,7 +22,7 @@ namespace RhythmBullet.Zer01HD.UI.Book
/// </summary>
/// <param name="camera">Camera game is currently using.</param>
/// <param name="dimensions">Dimensions of the book and the dimensions the pages will use.</param>
public void Initialize(Camera2D camera, Rectangle dimensions)
public void Initiate(Camera2D camera, Rectangle dimensions)
{
this.camera = camera;
this.dimensions = dimensions;