XNA: Die beste Übereinstimmung für die überladene....

tobee

Erfahrenes Mitglied
Bei Kompilieren meines Programmes bekomme ich folgendenen Fehler:
Fehler 1 Die beste Übereinstimmung für die überladene Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawString(Microsoft.Xna.Framework.Graphics.SpriteFont, string, Microsoft.Xna.Framework.Vector2, Microsoft.Xna.Framework.Graphics.Color)-Methode hat einige ungültige Argumente. C:\Dokumente und Einstellungen\root\Eigene Dateien\Visual Studio 2005\Projects\Wehrmacht\Wehrmacht\Game1.cs 70 13 Wehrmacht
Fehler 2 2-Argument: kann nicht von "Microsoft.Xna.Framework.Input.MouseState" in "string" konvertiert werden. C:\Dokumente und Einstellungen\root\Eigene Dateien\Visual Studio 2005\Projects\Wehrmacht\Wehrmacht\Game1.cs 70 38 Wehrmacht
Bei diesem Quellcode:
C:
#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion

namespace Wehrmacht
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {

        GraphicsDeviceManager graphics;
        ContentManager content;

        SpriteBatch Sprite;
        SpriteFont Arial;

        KeyboardState ksState;
        MouseState msState;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            content = new ContentManager(Services);
            this.IsMouseVisible = true;
        }

        protected override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadGraphicsContent(bool loadAllContent)
        {
            if (loadAllContent)
            {
                Arial = content.Load<SpriteFont>("Arial");
                Sprite = new SpriteBatch(graphics.GraphicsDevice);
            }
        }

        protected override void UnloadGraphicsContent(bool unloadAllContent)
        {
            if (unloadAllContent)
            {
                content.Unload();
            }
        }

        protected override void Update(GameTime gameTime)
        {
            ksState = Keyboard.GetState();
            msState = Mouse.GetState();
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            ksState = Keyboard.GetState();
            msState = Mouse.GetState();
            Sprite.Begin();
            Sprite.DrawString(Arial, msState, new Vector2(20, 20), Color.White);
            Sprite.End();
            base.Draw(gameTime);
        }
    }

}
Leider finde ich den Fehler nicht.
Ich möchte immer die aktuelle Mausposition und die aktuelle gedrückte Taste(n) ausgeben.
Ich bin mir nicht sicher ob ich das in die Draw oder Update Funktion reinmachen soll.
.
Danke für Tipps
 
Hi tobee,

versuch mal in der DrawString-Funktion mbState.ToString(). Im Gegensatz zu Visual Basic ist C# ebenso wie alle anderen C-Sprachen nämlich relativ pingelig was die Typkonvertierung angeht.

Gruß
PhoenixLoe
 
Zurück