refactor: implemented engine's ILoadContent for loading content
This commit is contained in:
parent
cc0476186e
commit
44a366f475
2
Engine
2
Engine
@ -1 +1 @@
|
|||||||
Subproject commit 65cfaf1b4a0d09eb396b3fdc98c52539af384f36
|
Subproject commit ad365dc7225df5df0d8be0729f6c62490c845f77
|
@ -1,3 +1,4 @@
|
|||||||
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
using Syntriax.Engine.Core;
|
using Syntriax.Engine.Core;
|
||||||
@ -5,7 +6,7 @@ using Syntriax.Engine.Integration.MonoGame;
|
|||||||
|
|
||||||
namespace Pong.Behaviours;
|
namespace Pong.Behaviours;
|
||||||
|
|
||||||
public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate
|
public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate, ILoadContent
|
||||||
{
|
{
|
||||||
public readonly bool IsLeft = IsLeft;
|
public readonly bool IsLeft = IsLeft;
|
||||||
|
|
||||||
@ -13,9 +14,6 @@ public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate
|
|||||||
|
|
||||||
public void FirstActiveFrame()
|
public void FirstActiveFrame()
|
||||||
{
|
{
|
||||||
MonoGameWindow monoGameWindow = Universe.FindRequiredBehaviour<MonoGameWindowContainer>().Window;
|
|
||||||
Font = monoGameWindow.Content.Load<SpriteFont>("UbuntuMono");
|
|
||||||
|
|
||||||
pongManager = Universe.FindRequiredBehaviour<PongManager>();
|
pongManager = Universe.FindRequiredBehaviour<PongManager>();
|
||||||
|
|
||||||
pongManager.OnScoreUpdated += UpdateScores;
|
pongManager.OnScoreUpdated += UpdateScores;
|
||||||
@ -24,6 +22,11 @@ public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate
|
|||||||
UpdateScores(pongManager);
|
UpdateScores(pongManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadContent(ContentManager content)
|
||||||
|
{
|
||||||
|
Font = content.Load<SpriteFont>("UbuntuMono");
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateScores(PongManager pongManager)
|
private void UpdateScores(PongManager pongManager)
|
||||||
{
|
{
|
||||||
if (IsLeft)
|
if (IsLeft)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user