シューティングゲーム改: 重力の働く弾と働かない弾を混ぜる #2
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
注: このDraft PRは「さらにステップアップ」の説明用です。実際にマージを要求するものではありません。
概要
Chapter 8の「シューティングゲーム改」の開発では、まずは弾に重力が働かず部屋の中を浮遊する版を作成し、次に重力を働かせて弾が床に落ちるようにしました。本ステップアップでは、重力の働く弾と働かない弾がランダムで混ざるようにし、空間コンピューティングならではの非現実的な体験を作り出してみます。
差分の確認とコードの修正
Files changedタブを開いて差分を確認し、アプリを修正してください。
ShootingLogic.swift
のshoot
メソッド内です。+
で始まる行を追加、-
で始まる行を削除してください。動作確認
修正後、Vision Pro実機またはシミュレータでアプリを実行してください。重力の働く緑の弾と重力の働かない赤い弾とがランダムで発射されます。
うまく動かないなど、答え合わせが必要な人はこのリンクから本修正適用済みのアーカイブをダウンロードし、
Chapter8
フォルダを参照してください。解説
ソース差分上のコメントを参照してください。