Hi leute,
seit einiger zeit beschäftige ich mich schon mit c# und nun hab ich mal noch XNA hinzugezogen
ich bin momentan dabei mir die tutorials von
www.xnatutorials.com anzuschauen und habe (fast) alles so gemacht wie der "Macher" von diesem Tutorial.
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: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75:
| using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; using Microsoft.Xna.Framework.Net; using Microsoft.Xna.Framework.Storage;
namespace WindowsGame3 { class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; ContentManager content; SpriteBatch spriteBatch; Texture2D myTexture; Vector2 spritePosition;
#region Mainmethodes
public Game1() { this.graphics = new GraphicsDeviceManager(this); this.content = new ContentManager(this.Services); }
protected override void Initialize() { this.spritePosition = new Vector2(100, 50); base.Initialize(); }
protected void LoadGraphicsContent(bool loadAllContent) { if (loadAllContent) { this.myTexture = this.content.Load<Texture2D>(@"Quellen\textures\formatieren"); this.spriteBatch = new SpriteBatch(this.graphics.GraphicsDevice); } }
protected override void UnloadGraphicsContent(bool unloadAllContent) { }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); base.Update(gameTime); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); this.spriteBatch.Begin(SpriteBlendMode.AlphaBlend); this.spriteBatch.Draw(this.myTexture, this.spritePosition, Color.White); this.spriteBatch.End(); base.Draw(gameTime); } #endregion } } |
An markierterStelle kommt immer NullReferenceExpection nicht behandelt, was ich nicht so ganz verstehe da ich ja weiter oben bei LoadGraphicsContent einen neuen spriteBatch eingeführt habe...Kann mir vielleicht jemand helfen??