Autor Beitrag
Pepsi
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Di 14.06.11 19:06 
Habe ein Problem...
Bin noch ziemlicher Anfänger, das hier ist mein erstes Projekt, daher nicht über die vielen Fehler wundern... :lol:
der Compiler hat mir alle Gleichheitszeichen und alle Klammern im unteren drittel angestrichen! Außerdem auch die Felder "recPlayerPositionAndDimision"
wär nett wenn mir jemand helfen wprde! :D :D [/user][/quote]
hier der Quelltext:

ausblenden volle Höhe C#-Quelltext
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:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Firebirds
{
    public class Player
    {
        public Texture2D texPlayer;

        public Rectangle recPlayerPositionAndDimision;

        public void LoadContent(
            ContentManager Content, GraphicsDevice graphics);
    {
        
            texPlayer = Content.Load<Texture2D>("Graphics\\spitfire");
                
            recPlayerPositionAndDimision.X = Graphics.Viewport.Width / 2 - texPlayer.Width / 2;  
            recPlayerPositionAndDimision.Y = Graphics.Viewport.Height / 2 - texPlayer.Height / 2;             
            recPlayerPositionAndDimision.Width = texPlayer.Width;              
            recPlayerPositionAndDimision.Height = texPlayer.Height;        
        }

     public void Draw(SpriteBatch spiriteBatch)
            {
                spiriteBatch.Draw(texPlayer, recPlayerPositionAndDimision, Color.White);
                   
            }
    }
}


Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4798
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Di 14.06.11 20:11 
Hallo und :welcome: im Forum,

Du hast ein Semikolon ';' zu viel hinter 'LoadContent(...)'

P.S. Poste deinen Code in [ cs ] ... [ /cs ] - Tags (ohne die Leerzeichen) - du kannst dazu einfach deinen Beitrag editieren.
Trashkid2000
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 561
Erhaltene Danke: 137



BeitragVerfasst: Di 14.06.11 20:19 
Was ich zum Beitrag von user profile iconTh69 noch hinzufügen möchte:
Du initialisierst das Rectangle recPlayerPositionAndDimision nicht.
Wenn Du dann die Werte setzt, dann bekommst Du eine NullRefernceException.
Du könntest es entweder gleich so deklarieren und initalisieren
ausblenden C#-Quelltext
1:
private Rectangle recPlayerPositionAndDimision = new Rectangle();					
, oder in der Methode LoadContent(...) sowas schreiben:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
recPlayerPositionAndDimision = new Rectangle() 

  X = Graphics.Viewport.Width / 2 - texPlayer.Width / 2,
  Y = Graphics.Viewport.Height / 2 - texPlayer.Height / 2,
  Width = texPlayer.Width,
  Height = texPlayer.Height               
};
LG
Ralf Jansen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 4708
Erhaltene Danke: 991


VS2010 Pro, VS2012 Pro, VS2013 Pro, VS2015 Pro, Delphi 7 Pro
BeitragVerfasst: Di 14.06.11 20:59 
Zitat:
Du initialisierst das Rectangle recPlayerPositionAndDimision nicht.
Wenn Du dann die Werte setzt, dann bekommst Du eine NullRefernceException.


Rectangle ist auch in XNA ein struct. recPlayerPositionAndDimision ist also zwangsweise bereits initialisiert.
Trashkid2000
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 561
Erhaltene Danke: 137



BeitragVerfasst: Di 14.06.11 21:52 
Upps, kenne mich mit XNA nicht aus.
Nehme alles zurück...
Pepsi Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Do 16.06.11 17:16 
Vielen Dank euch allen !!!!!!!!!!!!! Hat mir echt geholfen!! :lol: :lol: