2

我正在尝试使用 isMouseVisible 让我的光标在 XNA 游戏中可见,但它不想工作。错误:

“StopWatch.Game1”不包含“isMouseVisible”的定义,并且找不到接受“StopWatch.Game1”类型的第一个参数的扩展方法“isMouseVisible”

代码:

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;

namespace StopWatch
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        public SpriteBatch spriteBatch;
        public static Game1 Instance;
        StopWatch stopWatch;

        public Game1()
        {
            this.isMouseVisible = true;
            graphics = new GraphicsDeviceManager(this);
            Instance = this;
            Content.RootDirectory = "Content";
            graphics.PreferredBackBufferWidth = 512;
            graphics.PreferredBackBufferHeight = 512;
        }

        protected override void Initialize()
        {
            stopWatch = new StopWatch(); 
            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            stopWatch.LoadContent();
        }

        protected override void UnloadContent()
        {
            stopWatch.UnloadContent();
        }

        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            stopWatch.Update(gameTime);
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();
            stopWatch.Draw(gameTime);
            spriteBatch.End();
            base.Draw(gameTime);
        }
    }
}
4

1 回答 1

2

利用IsMouseVisible = true

大写 I

请记住,使用 intelisence,您只需键入开头即可查看方法和变量。

于 2012-07-18T15:52:38.020 回答