tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
1
ZUGRIFFE
1624
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    Avatar von tobee
    tobee tobee ist offline Grolba.com media
    Registriert seit
    Jul 2005
    Ort
    Karlsruhe
    Beiträge
    1.700
    Blog-Einträge
    131
    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:
    Code c:
    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
    76
    
    #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
     

  2. #2
    PhoenixLoe PhoenixLoe ist offline Mitglied Gold
    Registriert seit
    Apr 2005
    Beiträge
    120
    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
     

Ähnliche Themen

  1. Antworten: 1
    Letzter Beitrag: 12.12.08, 11:33
  2. Antworten: 3
    Letzter Beitrag: 26.11.08, 09:20
  3. Substr_Count bei genauer Übereinstimmung
    Von Thomas_Jung im Forum PHP
    Antworten: 4
    Letzter Beitrag: 25.11.08, 13:32
  4. Antworten: 3
    Letzter Beitrag: 26.08.08, 12:10
  5. password übereinstimmung?
    Von moonlight-kknd im Forum Relationale Datenbanksysteme
    Antworten: 4
    Letzter Beitrag: 04.04.05, 21:06