ユーザ用ツール

サイト用ツール


unity2d:co-routine

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
unity2d:co-routine [2024/01/12 02:12] – [Coinの発射] yajuadminunity2d:co-routine [2024/01/12 02:13] (現在) – [C#スクリプト作成] yajuadmin
行 72: 行 72:
         if (other.tag == "DamageObject") {         if (other.tag == "DamageObject") {
                if(++count >= 6)                if(++count >= 6)
-                 Destroy(other.gameObject); //コインが6発当たれば敵を削除+                 Destroy(other.gameObject); // コインが6発当たれば敵を削除
                Destroy(this.gameObject);                Destroy(this.gameObject);
           }           }
行 78: 行 78:
  
     void OnBecameInvisible() {     void OnBecameInvisible() {
-        Destroy(this.gameObject); //カメラから外れたら削除+        Destroy(this.gameObject); // カメラから外れたら削除
     }     }
 } }
行 123: 行 123:
         bool jump = Input.GetButtonDown("Jump");         bool jump = Input.GetButtonDown("Jump");
         Move(x, jump);          Move(x, jump);
-        //左クリックでコイン発射+        // 左クリックでコイン発射
         if (Input.GetButtonDown("Fire1"))         if (Input.GetButtonDown("Fire1"))
-            StartCoroutine(“Shot”); //コルーチンを呼びます+            StartCoroutine(“Shot”); // コルーチンを呼びます
  }  }
      }      }
行 132: 行 132:
          if (isRunning) { yield break; }          if (isRunning) { yield break; }
          isRunning = true;          isRunning = true;
-         //コインを3連射する+         // コインを3連射する
          for(int i = 0; i<3; i++)  {          for(int i = 0; i<3; i++)  {
              Instantiate(Coin, new Vector2(transform.position.x + 0.5f,               Instantiate(Coin, new Vector2(transform.position.x + 0.5f, 
             transform.position.y - 0.5f), Quaternion.identity);             transform.position.y - 0.5f), Quaternion.identity);
-             yield return new WaitForSeconds(1f); //1秒待機+             yield return new WaitForSeconds(1f); // 1秒待機
         }         }
         isRunning = false;         isRunning = false;
unity2d/co-routine.1704993123.txt.gz · 最終更新: 2024/01/12 02:12 by yajuadmin