C# 统一触摸位置不工作
我的Android/iOS游戏有一些问题。 概念非常简单(纵向模式): 如果你点击屏幕的左侧,它会将球撞向右侧。 如果你点击屏幕的右侧,它会将球撞向左侧 问题是,我在控制器脚本中添加了以下代码:C# 统一触摸位置不工作,c#,android,ios,unity3d,C#,Android,Ios,Unity3d,我的Android/iOS游戏有一些问题。 概念非常简单(纵向模式): 如果你点击屏幕的左侧,它会将球撞向右侧。 如果你点击屏幕的右侧,它会将球撞向左侧 问题是,我在控制器脚本中添加了以下代码: void TouchManagement() { for(int i = 0; i< Input.touchCount; ++i) { Touch touch = Input.GetTouch(i); if(t
void TouchManagement()
{
for(int i = 0; i< Input.touchCount; ++i)
{
Touch touch = Input.GetTouch(i);
if(touch.phase == TouchPhase.Began)
{
Debug.Log(touch.position);
if(touch.position.x > Screen.width/2f && timer == 0f)
{
BumpLeft();
}
else if (touch.position.x <= Screen.width / 2f && timer == 0f)
{
BumpRight();
}
timer = cooldown;
}
}
}
void touch管理()
{
对于(int i=0;iScreen.width/2f&&timer==0f)
{
BumpLeft();
}
else if(touch.position.x)可能计时器不完全为0.0f?比较浮点值与相等值总是很棘手。如果Debug.Log(…)不起作用,请将触摸位置写入屏幕上的UI.Text。请添加指向其他论坛帖子和问题的链接。可能计时器不完全为0.0f?比较浮点值与相等值总是很棘手。如果Debug.Log(…)不工作,请将触摸位置写入UI。屏幕上的文本。请添加指向其他论坛帖子和问题的链接。