XNA - 没有'isMouseVisible'的定义

时间:2012-07-18 15:46:47

标签: c# xna

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

  

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

代码:

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);
        }
    }
}

1 个答案:

答案 0 :(得分:2)

使用IsMouseVisible = true

资本化我

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