forked from CodingMadeEasy/MonogameRPG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFadeEffect.cs
56 lines (49 loc) · 1.33 KB
/
FadeEffect.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
namespace YoutubeRPG
{
public class FadeEffect : ImageEffect
{
public float FadeSpeed;
public bool Increase;
public FadeEffect()
{
FadeSpeed = 1;
Increase = false;
}
public override void LoadContent(ref Image Image)
{
base.LoadContent(ref Image);
}
public override void UnloadContent()
{
base.UnloadContent();
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
if (image.IsActive)
{
if (!Increase)
image.Alpha -= FadeSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
else
image.Alpha += FadeSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
if (image.Alpha < 0.0f)
{
Increase = true;
image.Alpha = 0.0f;
}
else if (image.Alpha > 1.0f)
{
Increase = false;
image.Alpha = 1.0f;
}
}
else
image.Alpha = 1.0f;
}
}
}