Skip to content

Commit aefa3bf

Browse files
committed
added screen wipe helper methods
1 parent 6c8a490 commit aefa3bf

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

BenMakesGames.PlayPlayMini.GraphicsExtensions/BenMakesGames.PlayPlayMini.GraphicsExtensions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Company>Ben Hendel-Doying</Company>
66
<Description>Some GraphicsManager extensions for PlayPlayMini.</Description>
77
<Copyright>2023-2025 Ben Hendel-Doying</Copyright>
8-
<Version>7.0.0-rc1</Version>
8+
<Version>7.0.0-rc2</Version>
99

1010
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1111
<PackageTags>monogame playplaymini graphics extensions animations text</PackageTags>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using Microsoft.Xna.Framework;
2+
3+
namespace BenMakesGames.PlayPlayMini.GraphicsExtensions.GameStateTransitions;
4+
5+
/// <summary>
6+
/// Extension methods for doing quick screen wipes between game states
7+
/// </summary>
8+
public static class GameStateManagerExtensions
9+
{
10+
public static void ChangeStateWithScreenWipe<T>(
11+
this GameStateManager gsm,
12+
ScreenWipeDirection direction,
13+
Color? color = null
14+
) where T : GameState =>
15+
gsm.ChangeState<ScreenWipe, ScreenWipeConfig>(new ScreenWipeConfig()
16+
{
17+
PreviousState = gsm.CurrentState,
18+
NextState = gsm.CreateState<T>(),
19+
Color = color ?? Color.Black,
20+
Direction = direction
21+
});
22+
23+
public static void ChangeStateWithScreenWipe<T, TConfig>(
24+
this GameStateManager gsm,
25+
TConfig config,
26+
ScreenWipeDirection direction,
27+
Color? color = null
28+
) where T : GameState<TConfig> =>
29+
gsm.ChangeState<ScreenWipe, ScreenWipeConfig>(new ScreenWipeConfig()
30+
{
31+
PreviousState = gsm.CurrentState,
32+
NextState = gsm.CreateState<T, TConfig>(config),
33+
Color = color ?? Color.Black,
34+
Direction = direction
35+
});
36+
37+
/// <summary>Change to the given game state, via a screen wipe.</summary>
38+
/// <param name="gsm"></param>
39+
/// <param name="nextState">Game state to switch to.</param>
40+
/// <param name="direction">Direction of wipe.</param>
41+
/// <param name="color">Color of wipe (defaults to <see cref="P:Microsoft.Xna.Framework.Color.Black">Color.Black</see>)</param>
42+
public static void ChangeStateWithScreenWipe(
43+
this GameStateManager gsm,
44+
AbstractGameState nextState,
45+
ScreenWipeDirection direction,
46+
Color? color = null
47+
) =>
48+
gsm.ChangeState<ScreenWipe, ScreenWipeConfig>(new ScreenWipeConfig()
49+
{
50+
PreviousState = gsm.CurrentState,
51+
NextState = nextState,
52+
Color = color ?? Color.Black,
53+
Direction = direction
54+
});
55+
}

0 commit comments

Comments
 (0)