|变数 () 改变 ()|
變數 [ v] 改變 (1)
The Change () by () 积木 is a 变量类积木 and a 条形积木. The block will change the specified 变量 by a given amount. If the variable is a 字串 and not a number, it is set to the quantity the variable was to be changed by (转换 the string to 0).
Prior to Scratch 1.3, this block did not have a drop-down input listing the variables and instead there was an instance of it for each variable.
Some common uses for the Change () by () block:
- Changing the speed of an object
變數 [speed v] 設為 (2) x 設為 (-240) 重複無限次 x 改變 (speed) 變數 [speed v] 改變 (1) 說出 [Whee!!!] end
- Changing a level number
如果 <碰到 [goal v] ?> 那麼 變數 [level v] 改變 (1) end
- Changing the score in a game
如果 <碰到 [laser v] ?> 那麼 變數 [score v] 改變 (-5) end
- Main article: List of Block Workarounds
This block can be replaced by the following script:
變數 [variable v] 設為 ((variable) + (amount))
The blank space at the far right contains the number that will change the value —a positive number to increase and a negative number to decrease the variable.