From Test-Scratch-Wiki
This article discusses a technique used to make an object slide vertically, horizontally, or both while scrolling. This tutorial explains how to make an object slide in a scroller. Below is the script you will need:
| The values below are just used as an example. Adjust the values as necessary to best fit your 专案. |
當 @greenflag 被點擊
重複無限次
x 設為 ((scrollX) + (xpos))
end
當 @greenflag 被點擊
重複無限次
重複 (100) 次
變數 [xpos v] 改變 (2.5)
end
重複 (100) 次
變數 [xpos v] 改變 (-2.5)
end
end
Placing this script into a sprite will make it move back and forth while you are scrolling.
How it Works
The xpos 变量 determines how far the sprite should be offset from its original position if it were scrolling normally. This script makes it forever slide back and forth. This is similar to a Mario style platformer.