在XNA/C#中添加自定义游标?我目前正在使用XNA开发游戏。我想在我的游戏中添加一个光标(不是标准的Windows光标)。我已将精灵添加到我的内容文件夹中。我有找到鼠标位置的方法,但我不知道如何在窗口中显示光标。这是我用来查找鼠标位置的方法(我在Game1类的开头实例化了一个“MouseState”类):publicint[]getCursorPos(){cursorX=mouseState.X;cursorY=mouseState.Y;int[]mousePos=newint[]{cursorX,cursorY};返回鼠标位置;为光标图像加载一个Texture2D并简单地绘制它。类Game1:游戏{privateSpriteBatchspriteBatch;私有Texture2DcursorTex;私有Vector2cursorPos;protectedoverridevoidLoadContent(){spriteBatch=newSpriteBatch(GraphicsDevice);(){cursorPos=newVector2(mouseState.X,mouseState.Y);}protectedoverridevoidDraw(GameTimegameTime){spriteBatch.Begin();spriteBatch.Draw(cursorTex,cursorPos,Color.White);spriteBatch.End();如果你喜欢加载Windows光标(ani,cur),你可以看到这个:http://allenwp.com/blog/2011/04/04/changing-the-windows-mouse-cursor-in-xna/您还可以使用GUI并手动加载Windows光标来替换默认光标。以上就是C#学习教程:AddingcustomcursorsinXNA/C#?分享所有内容,如果对大家有用,需要进一步了解C#学习教程,希望大家多加关注——本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如有转载请注明出处:
