如何阅读android上的触摸屏输入

问题描述 投票:-3回答:1

我正在尝试使用monogame将一键式游戏移植到Android,但是当我第一次这样做时,我很难弄清楚如果用户按下屏幕我怎么能读。我也不确定使用什么库,大多数逻辑接缝Android.Gestures但我不知道如何使用它。

c# android monogame porting
1个回答
1
投票

定义触摸集合: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;

© www.soinside.com 2019 - 2024. All rights reserved.