看板 GameDesign 關於我們 聯絡資訊
各位前輩,小弟我在練習開發android上的遊戲 我在電腦上執行 SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex) ; 可以成功的重新開始這個scene 但是當我輸出成APK到手機上執行時 敵人就沒有辦法順利生成 我敵人生成的方式是在start()內呼叫 StartCoroutine (SpawnWaves ()); IEnumerator SpawnWaves (){ yield return new WaitForSeconds (startWait); while(true){ for (int i = 0; i < hazardCount; ++i){ Vector3 spawnPosition = new Vector3 (Random.Range (xMin, xMax), yMax, 0); //我有測試在這邊將xMin,xMax,yMax,hazard,hazardCount,i,Time.time顯示在螢幕上 //在還沒有重新執行時i都順利增加,Time.time也會跑,可是當我重新開始時i跟時間 //就只會卡在一個值了 Instantiate (hazard, spawnPosition, transform.rotation); yield return new WaitForSeconds (spawnWait); } yield return new WaitForSeconds (waveWait); if (gameOver) { restartText.text = "Double click to Restart"; restart = true; break; } } } 想請教各位前輩可以幫我提點一下嗎,謝謝 -- ███◣ ██◣ ███◣ ██◣ █◣ ███◣ █◣◥◣ █◣◥◣ ███ ██◣ ███ ██ ███ █▆▆ ▉▉▉ █▆█ █◣ ◢█◤ ███ ▆▆█ █ █ ██ ███ ███ ██◤ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▃▃▃▃▂▂▂▁▁ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.34.64.242 ※ 文章網址: https://www.ptt.cc/bbs/GameDesign/M.1483356647.A.4D3.html
gyd: 請定義 i跟time卡在一個值, 下次請試著將狀況講清楚 01/03 00:38
gyd: 沒有完整code的情況只能幫你抓邏輯錯誤而已 01/03 00:39
smailzhu: 我覺得time卡的那個值應該是進去for迴圈的那個時間點, 01/03 04:41
smailzhu: 至於i的話是卡再0不會增加 01/03 04:41
smailzhu: 謝謝提點,我晚點會Po程式碼 01/03 04:42
smailzhu: 我覺得最困擾的是,電腦上可以順利重來,可是手機無法 01/03 09:23
smailzhu: 程式碼在此付上http://ideone.com/zT7puQ 01/03 09:42