play sound example. Setup via settings

This commit is contained in:
Insality 2019-03-27 09:41:13 +03:00
parent 9d13837cf0
commit 349f73c515
3 changed files with 15 additions and 14 deletions

View File

@ -27,8 +27,8 @@ function M.init(instance, callback, params, animate_node_name, event)
instance.tap_anim = M.tap_scale_animation
instance.back_anim = M.back_scale_animation
instance.hover_anim = b_settings.IS_HOVER
-- instance.sound = sound or BTN_SOUND
-- instance.sound_disable = sound_disable or BTN_SOUND_DISABLED
instance.sound = b_settings.BTN_SOUND
instance.sound_disable = b_settings.BTN_SOUND_DISABLED
end
@ -45,7 +45,7 @@ local function on_button_release(instance)
if not instance.stub and instance.can_action then
instance.can_action = false
instance.tap_anim(instance)
-- instance.sound()
settings.play_sound(instance.sound)
instance.callback(instance.parent.parent, instance.params, instance)
else
set_hover(instance, false)
@ -89,7 +89,6 @@ function M.tap_scale_animation(instance)
if instance.back_anim then
instance.back_anim(instance)
end
-- instance.sound()
end
)
end

View File

@ -146,14 +146,5 @@ function M.create(factory, module, name, ...)
end
function M.get_text(name)
-- override to get text for localized text
end
function M.play_sound(name)
-- override to play sound with name
end
register_basic_components()
return M

View File

@ -4,7 +4,7 @@ local M = {}
M.button = {
IS_HOVER = true,
IS_HOLD = true,
BTN_SOUND = "button_click",
BTN_SOUND = "click",
BTN_SOUND_DISABLED = "button_click_disabled",
HOVER_SCALE = vmath.vector3(-0.025, -0.025, 1),
HOVER_TIME = 0.05,
@ -12,4 +12,15 @@ M.button = {
}
function M.get_text(name)
-- override to get text for localized text
end
function M.play_sound(name)
-- override to play sound with name
end
return M