我正在尝试使用monogame将一键式游戏移植到Android,但是当我第一次这样做时,我很难弄清楚如果用户按下屏幕我怎么能读。我也不确定使用什么库,大多数逻辑接缝Android.Gestures但我不知道如何使用它。
定义触摸集合:TouchCollection touchState;//get touches
在Update()
的Game1()
方法或您想要实现的类:
touchState = TouchPanel.GetState();
foreach (var touch in touchState)
{
if (touch.State == TouchLocationState.Pressed)
{
//do what you want here when users tap the screen
}
}
它使用using Microsoft.Xna.Framework.Input.Touch;