在 XNA/C# 中添加自定义光标?
我目前正在 XNA 中开发一款游戏。我想在游戏中添加一个光标(不是标准的 Windows 光标)。我已经将精灵添加到我的内容文件夹中。我有一种查找鼠标位置的方法,但我不知道应该如何在窗口中显示光标。
这是我用来查找鼠标位置的方法(我在 Game1 类的开头实例化了一个“MouseState”类):
public int[] getCursorPos()
{
cursorX = mouseState.X;
cursorY = mouseState.Y;
int[] mousePos = new int[] {cursorX, cursorY};
return mousePos;
}
I am currently developing a game in XNA. I would like to add a cursor (not the standard Windows one)to the game. I have already added the sprite to my contents folder. I have a method for finding the position of the mouse, but I don't know how I should go about displaying the cursor in the window.
Here is the method I am using to find the position of the mouse (I instantiated a "MouseState" class in the beginning of the Game1 class):
public int[] getCursorPos()
{
cursorX = mouseState.X;
cursorY = mouseState.Y;
int[] mousePos = new int[] {cursorX, cursorY};
return mousePos;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为光标图像加载一个Texture2D并简单地绘制它。
Load a Texture2D for the cursor image and simply draw it.
您还可以使用 GUI 并手动加载 Windows 光标来替换默认光标
you can also use GUI and manually load a windows cursor to replace the default cursor