improved transition system, target rendering portion tested with loading to main screen.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RhythmBullet.Zer01HD.Utilities.UI;
|
||||
using RhythmBullet.Zer01HD.Utilities.UI.ScreenSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -10,29 +11,22 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace RhythmBullet.Zer01HD.Game.Screens.Transitions
|
||||
{
|
||||
internal class FadeInTransition : IDisposable
|
||||
internal class FadeAwayTransition : IDisposable, ITransition
|
||||
{
|
||||
private const float RATE = 0.3f;
|
||||
public readonly Texture2D curtain;
|
||||
private const float TIME_REQUIRED = 2f;
|
||||
public Texture2D curtain;
|
||||
public Rectangle curtainSize;
|
||||
private Color color;
|
||||
private float progR, progG, progB, progA;
|
||||
private float rR, rG, rB, rA;
|
||||
internal FadeInTransition(GraphicsDevice graphicsDevice, Color startColor)
|
||||
{
|
||||
curtain = new Texture2D(graphicsDevice, 1, 1);
|
||||
curtain.SetData(new[] { Color.White });
|
||||
private float rR, rG, rB, rA;
|
||||
|
||||
color = startColor;
|
||||
}
|
||||
|
||||
internal void Init(Rectangle dimensions)
|
||||
internal FadeAwayTransition()
|
||||
{
|
||||
curtainSize = dimensions;
|
||||
rR = (0 - color.R) / RATE;
|
||||
rG = (0 - color.G) / RATE;
|
||||
rB = (0 - color.B) / RATE;
|
||||
rA = (0 - color.A) / RATE;
|
||||
color = Color.White;
|
||||
rR = (0 - 254) / TIME_REQUIRED;
|
||||
rG = (0 - 254) / TIME_REQUIRED;
|
||||
rB = (0 - 254) / TIME_REQUIRED;
|
||||
rA = (0 - 254) / TIME_REQUIRED;
|
||||
|
||||
progA = color.A;
|
||||
progR = color.R;
|
||||
@@ -40,7 +34,12 @@ namespace RhythmBullet.Zer01HD.Game.Screens.Transitions
|
||||
progB = color.B;
|
||||
}
|
||||
|
||||
internal bool Fade(float deltaf)
|
||||
public void InitiateTransition(Rectangle dimensions)
|
||||
{
|
||||
curtainSize = dimensions;
|
||||
}
|
||||
|
||||
private bool Fade(float deltaf)
|
||||
{
|
||||
if (progR > 0 || progG > 0 || progB > 0)
|
||||
{
|
||||
@@ -58,20 +57,32 @@ namespace RhythmBullet.Zer01HD.Game.Screens.Transitions
|
||||
color.A = (byte)progA;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void Draw(SpriteBatch batch)
|
||||
public void DrawTransition(SpriteBatch batch)
|
||||
{
|
||||
if (curtain != null)
|
||||
{
|
||||
batch.Draw(curtain, curtainSize, color);
|
||||
}
|
||||
batch.Draw(curtain, curtainSize, color);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
curtain.Dispose();
|
||||
}
|
||||
|
||||
public bool EnteringTransition(double delta, bool assetsLoaded)
|
||||
{
|
||||
return Fade((float)delta);
|
||||
}
|
||||
|
||||
public bool ExitingTransition(double delta, bool assetsLoaded)
|
||||
{
|
||||
return Fade((float)delta);
|
||||
}
|
||||
|
||||
public void UpdatePreviousScreenFrame(RenderTarget2D previousScreenFrame)
|
||||
{
|
||||
curtain = previousScreenFrame;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user