/RawSprite.cs
Created May 21, 2012
YNA Framework - Create custom Sprite with no texture
| using System; | |
| using System.Collections.Generic; | |
| using Microsoft.Xna.Framework; | |
| using Microsoft.Xna.Framework.Graphics; | |
| using Microsoft.Xna.Framework.Input; | |
| using Yna; | |
| using Yna.Display; | |
| namespace Yna.Test | |
| { | |
| public class RawSpriteState : Yna.YnState | |
| { | |
| Sprite background; | |
| Sprite player; | |
| public RawSpriteState() : base () | |
| { | |
| } | |
| public override void Initialize() | |
| { | |
| base.Initialize(); | |
| background = new Sprite(Vector2.Zero, "2d//green-world"); | |
| player = new Sprite(new Rectangle(0, 0, 50, 50), Color.Azure); | |
| player.ForceInsideOutsideScreen = true; | |
| Add(background); | |
| Add(player); | |
| } | |
| public override void Update(GameTime gameTime) | |
| { | |
| base.Update(gameTime); | |
| if (YnG.Keys.Escape) | |
| YnG.Quit(); | |
| if (YnG.Keys.Up) | |
| player.Y = player.Y - 1 * gameTime.ElapsedGameTime.Milliseconds; | |
| if (YnG.Keys.Down) | |
| player.Y = player.Y + 1 * gameTime.ElapsedGameTime.Milliseconds; | |
| if (YnG.Keys.Left) | |
| player.X = player.X - 1 * gameTime.ElapsedGameTime.Milliseconds; | |
| if (YnG.Keys.Right) | |
| player.X = player.X + 1 * gameTime.ElapsedGameTime.Milliseconds; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment