Pardon the mess, Play My Code is in beta!

READY TO PLAY?
CLICK TO LOG IN!

sign up - lost password

setVolume

setVolume( volume )

Sets the global volume, which is multiplied against the volume in all Sound objects. The volume value given must be between 0.0 and 1.0.

// fades the volume from 0, up to 1, over 1 second

SECOND = 1000.0
time = 0
setVolume( 0 )

onEachFrame() do |delta|
    time = time+delta
    volume = ( time / SECOND ).min( 1 )

    setVolume( volume )
end

See Also