Hallo,
ich bin vor kurzem auf XNA gestoßen - bin also Neuling. Wenn ich jetzt mein Game Lade, kommt beim Laden einer SpriteFont die oben genannte Exception.
Ich Lade diese Font außerhalb der
LoadContent Methode. Genauergesagt in einer anderen Klasse.
Hier der Code:
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:
| namespace xyz { public partial class Game1 : Game { protected GraphicsDeviceManager graphics; protected SpriteBatch spriteBatch;
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; }
protected override void LoadContent() { Video video = Content.Load<Video>("Intro"); videoPlayer.Play(video); GameMode = GameMode.None; font = Content.Load<SpriteFont>("Courier New"); spriteBatch = new SpriteBatch(GraphicsDevice); player.Texture = Content.Load<Texture2D>("breaker"); player.Speed = SCREENWIDTH / 10; Menu.Load(); GameState = GameState.Loaded; } } } |
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:
| namespace xyz { public class Menu : Game1 {
public void Load() { StringStartPosition = WINDOW.Height / 5; StringDistance = WINDOW.Height / 10; Font = Content.Load<SpriteFont>("MenuFont"); Strings.Add(new SelectableString("You vs the Clock", Font, "Reach the goal as fast as you can. The clock is ticking!")); Strings.Add(new SelectableString("Apocalyptic Mode", Font, "Reach the goal as fast as you can. You have weapons and other usefull things. Use them! The clock is ticking!")); Strings.Add(new SelectableString("Create Map", Font, "Create your own maps and play them.")); Strings.Add(new SelectableString("Options", Font, "Change the settings of the game")); Strings.Add(new SelectableString("Exit", Font, "Leave the game. Are you sure?")); Background = Content.Load<Texture2D>("Menu"); Color = Set.MenuColor; SelectionColor = Set.MenuSelectedColor; Strings[0].Select = true; SelectedString = 0; InfoText = Strings[0].TextInfo; } } } |
Weiß jemand wie ich das beheben kann?
Der längste Typ-Name im .NET-Framework ist: ListViewVirtualItemsSelectionRangeChangedEventHandler