--------------------------------------------------------------------------------
--  File     : PlaySoundWithDelay.lua
--  Author(s): Prokopovich Larisa
--
--  Summary  : Проиграть звук после паузы.
--
--  Copyright © 2012 Floodlight Games.  All rights reserved.
--------------------------------------------------------------------------------
delay_sound = 0
delay_sound_dt = 0
is_delay_sound = false
name_sound = ""
--------------------------------------------------------------------------------
function PlaySoundWithDelay(nameSound, delay)
	if not(is_delay_sound) then				
		is_delay_sound = true			--запустить отсчет паузы
		delay_sound = delay
		name_sound = nameSound
	else
		room.sfx:Play (nameSound)		--закончить отсчет паузы
		is_delay_sound = false
		delay_sound_dt = 0
	end
end
--------------------------------------------------------------------------------
function OnUpdateDelay (elapsedTime)
	if is_delay_sound then
		delay_sound_dt = delay_sound_dt + elapsedTime
		if delay_sound_dt >= delay_sound then
			PlaySoundWithDelay(name_sound, delay_sound)
		end
	end
end