我在场景中的任意位置为objectCreation编写了一个方法。我希望在我的游戏中,当玩家滑动屏幕时发生这种情况。我正在使用下面的代码
void Start(){
StartCoroutine (SwipeInput ());
}
void Update(){
if (Swiped) {
if (Direction == Vector2.up) {
RandomObjects ();
} else if (Direction == Vector2.right) {
RandomObjects ();
} else if (Direction == -1 * Vector2.up) {
RandomObjects ();
} else if (Direction == -1 * Vector2.right) {
RandomObjects ();
}
}
}
IEnumerator SwipeInput ()
{
while(true){
if (Input.touchCount > 0) {
Touch t = Input.GetTouch (0);
Swiped = false;
Vector2 initial = t.position;
yield return new WaitForSeconds (0.5f);
Direction = (t.position - initial).normalised;
Swiped = true;
yield return new WaitForSeconds (0.5f);
} else {
Swiped = false;
}
}
}但是这个游戏不能在Coroutine中使用while(true)。谢谢。
发布于 2014-07-08 17:15:04
你应该写"normaliZed“而不是"normaliSed”
https://stackoverflow.com/questions/24248305
复制相似问题