From Test-Scratch-Wiki
- "Wait" redirects here. For the other Control block with "wait" in its name, see Wait Until () (block).
等待 () 秒 | |
等待 () 秒 | |
类别 | 控制类积木 |
加入於 | 0.1 |
The Wait () Secs 积木 is a 控制类积木 and a 条形积木. The block pauses its 程式 for the specified amount of seconds — the wait can also be a decimal number.
This block is the most commonly used blocks [factually inaccurate?]; it is used whenever a sprite must wait for another action.
用法示例
This block creates a pause whenever needed — as there are many situations where this is need, the block is used in many 专案. Some common uses:
- Timers
重複無限次 等待 (60) 秒 造型換成下一個 end
- 动画类专案 delays
重複 (10) 次 等待 (0.05) 秒 造型換成下一個 end
- Virtual 模拟类专案
等待 (300) 秒 廣播訊息 [Morning v]
當 @greenflag 被點擊 變數 [var v] 設為 [0] 等待 (0) 秒 變數 [var v] 改變 (1)
- In the Flash Player, allowing the page to refresh so sprites can sense objects made by the pen.
蓋章 定位到 x: (-50) y: (0) 等待 (0) 秒 重複直到 <碰到顏色 [#000000] ?> x 改變 (1) 等待 (0) 秒 end
Workarounds
- Main article: List of Block Workarounds
This block can be replicated using any of the following scripts:
Using the Timer
計時器重置 等待直到 <<(計時器) < (value)> 不成立>
However, if the project resets the timer for other purposes, a different workaround should be used.
變數 [variable v] 設為 (計時器) 等待直到 <<((計時器) - (variable)) < (wait duration)> 不成立>
The workaround uses the timer as a base instead of a player-made clock because the timer is more accurate; player-made clocks lag from the time it takes to change the clock variable.
===Using Glide () Secs to X: () Y: ()===
滑行 (wait duration) 秒到 x: (x 座標) y: (y 座標)
This workaround will muddle whatever movement the sprite is performing at the time, so it is best to keep the workaround to immobile sprites.
===Using Say () for () Secs or Think () for () Secs===
說出 [ ] (wait duration) 秒
想著 [ ] (wait duration) 秒
These two workarounds will ruin any thoughts or sayings that the sprite has at the time, so they should only be used on sprites that do not think or talk.
===Using Rest for () Beats===
演奏休息 <((演奏速度) / (60)) * (wait duration)> 拍
===Using Play Sound () Until Done===
Note: | This is assuming that the sound is exactly the wanted length. |
播放音效 [silent sound v] 到底