繁体   English   中英

将Input.GetAxis转换为触摸屏

[英]Converting Input.GetAxis to touch screen

我刚刚使用C#在Unity中创建了一个Pong游戏。 它可以在计算机上运行,​​但我也希望它可以在Windows Phone上运行。 我相信我必须将Input.GetAxis更改为某种触摸控件,但我不知道该怎么做

我将在此处将我的代码发布到键盘上。 另一个桨是AI。

public float PaddleSpeed = 1;
public Vector3 PlayerPos;

void Update ()
{
    float yPos = gameObject.transform.position.y + (Input.GetAxis ("Vertical") * PaddleSpeed);
    PlayerPos = new Vector3 (-315, Mathf.Clamp (yPos, -148,148),0);
    gameObject.transform.position = PlayerPos;
}

您可能需要添加一些条件编译器指令。 看到这个页面:

http://docs.unity3d.com/Manual/PlatformDependentCompilation.html

所以:

#if UNITY_WP8
   // touch code for windows phone 8
#else
    // any other platform
#endif

对于触摸输入,应使用@Bart的注释。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM