feature/task-tweens #30
@ -40,7 +40,7 @@ end
|
|||||||
--- @param ms number? in milliseconds
|
--- @param ms number? in milliseconds
|
||||||
function audio:crossfade(from, to, ms)
|
function audio:crossfade(from, to, ms)
|
||||||
print("[Audio]: Triggered crossfade")
|
print("[Audio]: Triggered crossfade")
|
||||||
|
|
||||||
-- Stop previous 'from' if it's dangling to avoid leaks
|
-- Stop previous 'from' if it's dangling to avoid leaks
|
||||||
if self.from and self.from ~= from and self.from ~= to then
|
if self.from and self.from ~= from and self.from ~= to then
|
||||||
self.from:stop()
|
self.from:stop()
|
||||||
@ -54,7 +54,7 @@ function audio:crossfade(from, to, ms)
|
|||||||
-- Reuse fader object to allow task cancellation
|
-- Reuse fader object to allow task cancellation
|
||||||
if not self.fader then self.fader = { value = 0 } end
|
if not self.fader then self.fader = { value = 0 } end
|
||||||
self.fader.value = 0
|
self.fader.value = 0
|
||||||
|
|
||||||
task.tween(self.fader, { value = 1 }, ms or 1000, ease.easeOutCubic)(function()
|
task.tween(self.fader, { value = 1 }, ms or 1000, ease.easeOutCubic)(function()
|
||||||
if self.from then
|
if self.from then
|
||||||
self.from:setVolume(0)
|
self.from:setVolume(0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user