source: 2015/26/MikkoL/JRPG/JRPG/Jypeli/Background.cs @ 6415

Revision 6415, 1.4 KB checked in by mijoliim, 5 years ago (diff)
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
5using Microsoft.Xna.Framework;
6using Microsoft.Xna.Framework.Graphics;
7
8namespace Jypeli
9{
10
11    public class _Background : Widget
12    {
13        SpriteBatch spriteBatch;
14       
15        Texture2D Texture { get; set; }
16        Microsoft.Xna.Framework.Color Tint = Microsoft.Xna.Framework.Color.White;
17
18        public bool UseShaders = true;
19        public Effect Shader;
20
21        public _Background(Texture2D Image)
22            : base(0, 0)
23        {
24            spriteBatch = Jypeli.Graphics.SpriteBatch;
25            Shader = Game.Instance.Content.Load<Effect>("Wave2");
26            Texture = Image;
27        }
28
29        protected override void Draw(Matrix parentTransformation, Matrix transformation)
30        {
31            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
32            if (UseShaders)
33            {
34                Shader.Parameters["parameter1"].SetValue((float)Game.Time.SinceStartOfGame.TotalMilliseconds);
35                Shader.CurrentTechnique.Passes[0].Apply();
36            }
37
38            spriteBatch.Draw(Texture, new Vector2(-(Texture.Width - Game.GraphicsDevice.Viewport.TitleSafeArea.Width) / 2, -(Texture.Height - Game.GraphicsDevice.Viewport.TitleSafeArea.Height) / 2), Tint);
39
40            spriteBatch.End();
41           
42            base.Draw(parentTransformation, transformation);
43        }
44    }
45}
Note: See TracBrowser for help on using the repository browser.