【发布时间】:2016-11-10 20:31:50
【问题描述】:
我正在制作一款跑步游戏,但我面临着一个大问题。 在这个阶段,障碍物被创造出来。但一段时间后,团结并没有成为新的障碍。为什么会这样?
public class GameManager : MonoBehaviour {
public float waitingTime = 1.5f;
public static GameManager manager;
public bool ready = true;
public GameObject cactus;
float time = 0;
// Use this for initialization
void Start () {
manager = this;
}
// Update is called once per frame
void Update () {
time += Time.deltaTime;
//Debug.Log(time);
if(time>2f && ready==true)
{
ready = false;
time = 0;
InvokeRepeating("MakeCactus", 1f, waitingTime);
}
}
void MakeCactus()
{
Instantiate(cactus);
}
public void GameOver()
{
//CancelInvoke("MakeCactus");
iTween.ShakePosition(Camera.main.gameObject, iTween.Hash("x", 0.2, "y", 0.2, "time", 0.5f));
}
}
【问题讨论】:
-
实例化更新成本高,使用池显示和隐藏预实例化对象