This tutorial will explain how to make resume/pause custom blocks that give users the ability to pause and resume sounds in a project.

Pausing Sounds

This script will make sounds pause:

define Pause
set volume to (0)%
set [pitch v] effect to ([log v] of ()) // keep the input blank

Another way you can do this is to put this block at the end, which still has the same effect.

 set [pitch v] effect to ((-1) / (0)) // this equals -infinity 

This works because the pitch effect blocks can slow down and speed up sounds. However, the minimum the pitch effect can go is a value -360, meaning that it is impossible to fully pause sounds using the pitch effect blocks. That is the reason the set volume to 0 block is needed, otherwise you would still be able to hear the sound. While it may be impossible to fully pause sounds this way, you could still get very close using this method.

Resuming Sounds

This script will make the sounds resume:

define Resume
set volume to (100)%
set [pitch v] effect to (0)

This code just reverts the effects of the "pause sound" custom block.

Music

The music is optional:

when green flag clicked
forever
play sound [Music v] until done
end

Another example of making music pause or resume can be found here.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.