proper splash screen loading as well as proper unloading assets for end of game finished.
This commit is contained in:
@@ -34,7 +34,8 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
try
|
||||
{
|
||||
assets.Add(assetName, contentManager.Load<IDisposable>(path));
|
||||
} catch (ContentLoadException cle)
|
||||
}
|
||||
catch (ContentLoadException cle)
|
||||
{
|
||||
Debug.WriteLine("Failed to load " + assetName + "with modified path: " + cle.Message);
|
||||
Debug.WriteLine("Loading asset from root: " + assetName);
|
||||
@@ -99,10 +100,13 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
/// <param name="name">the string name used to load the asset</param>
|
||||
public void Remove(string name)
|
||||
{
|
||||
if (assets.ContainsKey(name))
|
||||
lock (queue)
|
||||
{
|
||||
assets[name].Dispose();
|
||||
assets.Remove(name);
|
||||
if (assets.ContainsKey(name))
|
||||
{
|
||||
assets[name].Dispose();
|
||||
assets.Remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,12 +126,12 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
/// </summary>
|
||||
public void UnloadAll()
|
||||
{
|
||||
foreach (KeyValuePair<string, IDisposable> asset in assets)
|
||||
lock (queue)
|
||||
{
|
||||
asset.Value.Dispose();
|
||||
assets.Remove(asset.Key);
|
||||
contentManager.Unload();
|
||||
assets.Clear();
|
||||
ClearQueue();
|
||||
}
|
||||
ClearQueue();
|
||||
}
|
||||
|
||||
public bool Done
|
||||
|
@@ -5,20 +5,46 @@ using RhythmBullet.Zer01HD.UI;
|
||||
using RhythmBullet.Zer01HD.Utilities.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RhythmBullet.Zer01HD.Game
|
||||
{
|
||||
class LoadingScreen : Screen
|
||||
class SplashScreen : Screen
|
||||
{
|
||||
Texture2D recrown;
|
||||
Rectangle rectangleBounds;
|
||||
public LoadingScreen(Texture2D recrown, Rectangle bounds)
|
||||
float proportion = 0.4f;
|
||||
RhythmBulletGame rhythmBullet;
|
||||
float progress;
|
||||
public SplashScreen(RhythmBulletGame rhythmBullet, Rectangle dimensions)
|
||||
{
|
||||
this.recrown = recrown;
|
||||
this.rectangleBounds = bounds;
|
||||
this.recrown = rhythmBullet.Content.Load<Texture2D>("RhythmBullet");
|
||||
this.rhythmBullet = rhythmBullet;
|
||||
rectangleBounds = new Rectangle(0, 0, (int)(dimensions.Height * proportion), (int)(dimensions.Height * proportion));
|
||||
rectangleBounds.X = (dimensions.Width - rectangleBounds.Width) / 2;
|
||||
rectangleBounds.Y = (dimensions.Height - rectangleBounds.Height) / 2;
|
||||
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (progress < 0.8f)
|
||||
{
|
||||
float delta = (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
progress += (delta/6f);
|
||||
if (progress > 1f)
|
||||
{
|
||||
progress = 1f;
|
||||
}
|
||||
rhythmBullet.BackgroundColor.R = (byte)(progress * 255);
|
||||
rhythmBullet.BackgroundColor.G = (byte)(progress * 255);
|
||||
rhythmBullet.BackgroundColor.B = (byte)(progress * 255);
|
||||
|
||||
}
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
|
Reference in New Issue
Block a user