CodingTrain / CodingTrain/Suggestion-Box
Question regarding Object Communication video 7.7
- 主要言語
- 言語のデータがありません
- スター
- 570
- フォーク
- 85
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Hello! I have a question in regards to the final result of the object communication code found in your program at the end of the 7.7 video. The code reads like this:
`for (b of bubbles) {`
` b.show();`
` b.move();`
` let overlapping = false;`
` for (other of bubbles) {`
` if (b !== other && b.intersects(other)) {`
` overlapping = true;`
` }`
` }`
` if (overlapping) {`
` b.changeColor(255);`
` } else {`
` b.changeColor(0);`
` }`
`}`
Please forgive me if I cannot ask this question properly: How would you, in this example, reference the *other* object within the *b* object's code? For example...
Let's say I want to draw a line that is 500 pixels long from the x and y of the *b* object at a random angle outwards every frame. Now, if an *other* object is "within range", so within 500 pixels of the *b* object, then draw the line from the x and y of the *b* object to the x and y of the *other* object (now less than 500 pixels long).
In the case above, I would need to pull the x and y coordinates of the *b* object and the *other* object within the same scope. The problem that I am having is that the if statement regarding overlapping being true or false is removed from the scope of the `for (other of bubbles)` loop, and as explained in the video, is necessary to avoid the problem of only-last-object interaction. So how could you remove the *other* object from scope while also running through the for loop every frame, while simultaneously avoiding the only-last-interaction problem?
Thank you!
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
ペイロードは Object Communication の動画 7.7 と、そこで示されている最終的なコードを指しています。まず、その例と質問のスコープ規則を確認してください。完了の条件は、最後のオブジェクトだけが対象になるインタラクションの問題を再導入せずに、両方のオブジェクトへのアクセスを扱う、文書化された説明を提供することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- content
- issue の種類
- ドキュメント
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100