It looks like you're new here. If you want to get involved, click one of these buttons!
music = Sound.new("mus/heal.wav") channel:setVolume(0.0) print(channel:getVolume()) channel = music:play(0, 1) print(channel:getVolume()) |
Dislikes: underbliss, Fiam
Comments
when you call music:play(), it returns new channel, so volume will back to 1. If you want to play sound/music with custom volume, you can write some util funtions
It should be normal way to set volume for channel.
you can set the volume or get the volume after it.
For example alpha is a property of Sprite and its default value is 1:
Likes: atilim
It should be transparent way to set default values for these things.
And why do we need separation of Sound and Sound channel? To download music once and play over and over? (To save memory.)
It would be great to have a resource pool with lazy loading for music and other resources. Then you could get rid of classes like SoundChannel
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
I actually like SoundChannel, especially with the events.
There's also the concept of sound layers (background, fx e.g. weapons, bonuses/pick-ups, music, UI). So maybe we can have the SoundChannel subscribe to event notifications for the "layer" it's on, to keep track of the global layer gain/volume, then it's a matter of wrapping setVolume() to apply that correction. I'm working on something similar, so I'll test this theory..