From Test-Scratch-Wiki
分身 () 建立 | |
分身 () 建立 | |
类别 | 控制类积木 |
形狀 | 条形积木 |
加入於 | 2.0 |
The Create Clone of () 积木 is a 控制类积木 and a 条形积木. It creates a 分身 of the sprite in the 参数. It can also clone the sprite it is running in, creating clones of clones, recursively.
历史
In the Scratch Day 2011 pre-alpha, this block was called Create Clone, with no argument. As such, it could only create a clone of the sprite it ran in; not others. The advantage of an argument is that a single sprite, or the 舞台, can clone several different sprites upon an 事件.
用法示例
Cloning is often used when a sprite must make copies of itself. Below are some examples:
- Unlimited bullets in a shooting game
當 [空白 v] 鍵被按下 分身 [bullet v] 建立
當分身產生 定位到 [player v] 位置 面朝 [滑鼠游標 v] 向 重複直到 <<碰到 [邊緣 v] ?> 或 <碰到 [target v] ?>> 移動 (3) 點 end 分身刪除
- Creating several copies of a sprite to click
當 @greenflag 被點擊 變數 [sprites to find v] 設為 [10] 重複 (sprites to find) 次 分身 [Sprite1 v] 建立 end
當分身產生 等待直到 <<滑鼠鍵被按下?> 且 <碰到 [滑鼠游標 v] ?>> 說出 [You got me!] (2) 秒 隱藏 變數 [sprites to find v] 改變 (-1)