临时解决MonoGame中使用Mouse.GetState()获取坐标点始终为0的方法
MonoGame 3.5.1在iOS,Windows Phone(其他平台未测试)中使用Mouse.GetState()方式获取坐标点始终是0。这是MonoGame的一个Bug。
解决办法:
1.等官方修复,请关注MonoGame最新进展 https://github.com/MonoGame/MonoGame
2.自己下载源码修复
3.本站提供临时解决办法:
1 2 3 4 5 6 7 8 9 |
var touches = TouchPanel.GetState(); if (touches.Count > 0) { ms = new MouseState((int)touches[0].Position.X, (int)touches[0].Position.Y, 0, ButtonState.Pressed, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released); } else { ms = Mouse.GetState(); } |
如果您对C#游戏开发感兴趣,可以扫下面二维码加入我们的QQ群来一起学习交流
原创文章,转载请注明本文链接地址(违者必究):临时解决MonoGame中使用Mouse.GetState()获取坐标点始终为0的方法