How to Create a Zoom Effect

Материал из Поле цифровой дидактики
Версия от 00:50, 7 июня 2022; scratch>Jvvg
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)

Шаблон:Expand A zoom effect is when a sprite zooms in when it is clicked or held, but when the mouse lets go, it goes back to its normal size. The zoom effect can be used on a sprite or background.

Methods

Method 1

This is the following script to make a sprite zoom in (for a method where the sprite can be moved by the mouse when zoomed in, see Method 2): Шаблон:Note

when gf clicked
set size to (. . .::grey)%
forever
if <<touching (mouse pointer v)?> and <mouse down?>> then
repeat until <(size) = (. . .::grey)>//Make sure this number is less than the sprites size limit or this script will break.
change size by (. . .::grey)//Make sure this number is less than the sprites size limit or this script will break.
end
else
repeat until <(size) = (. . .::grey)>// Set this to the regular size.
change size by (. . .::grey)//Must be the number that increases the image but negative (i.e 10 becomes -10)
end
end
end

Method 2

This is the following script to make a sprite zoom in and be able to move (for a method where the sprite zooms in but can not be moved, see Method 1):

Шаблон:Note

when gf clicked
set size to (. . .::grey)%
go to x: (. . .::grey) y: (. . .::grey)//Set the x and y to the regular x and y position.
forever
if <<touching (mouse pointer v)?> and <mouse down?>> then
repeat until <(size) = (. . .::grey)>//Make sure this number is less than the sprites size limit or this script will break.
change size by (. . .::grey)//Make sure this number is less than the sprites size limit or this script will break.
end
repeat until <not <mouse down?>>
go to (mouse pointer v)
end
else
repeat until <(size) = (. . .::grey)>// Set this to the regular size.
change size by (. . .::grey)//Must be the number that increases the image but negative (i.e 10 becomes -10)
end
go to x: (. . .::grey) y: (. . .::grey)//Set the x and y to the regular position.
end