Making Objects Move in Scrollers

Материал из Поле цифровой дидактики
Описание Как организовать скроллинг в Scratch
Область знаний Математика
Область использования (ISTE)
Возрастная категория


Поясняющее видео
Близкие рецепту понятия
Среды и средства для приготовления рецепта:

This tutorial explains how to make an object move in a scroller.

How it Works

The xpos variable 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. Below is the script that is needed:


whenclickedforever...gotox:scrollX+xposy:scrollY+ypos...end

If a large costume is selected, it can be made to hide when it's touching the edge by adding this to the forever loop:

...ifabsofscrollX+xpos>240orabsofscrollY+ypos>180thenhide...elseshow...end...

The following script will change the 'x pos' relative to the entire scrolling.

whenclickedforeverrepeat100changexposby2.5endrepeat100changexposby-2.5endend

See Also