From 82b15243fc0eb23d9d47b7042a3a23e7e3e817a8 Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 7 Apr 2019 12:14:43 +0300 Subject: [PATCH] Can setup additional zone to check button click --- druid/base/button.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/druid/base/button.lua b/druid/base/button.lua index e36802d..48a1d2b 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -30,6 +30,7 @@ function M.init(instance, node, callback, params, anim_node, event) instance.hover_anim = b_settings.IS_HOVER instance.sound = b_settings.BTN_SOUND instance.sound_disable = b_settings.BTN_SOUND_DISABLED + instance.ext_zone = nil end @@ -68,7 +69,12 @@ function M.on_input(instance, action_id, action) return false end - if gui.pick_node(instance.node, action.x, action.y) then + local is_pick = gui.pick_node(instance.node, action.x, action.y) + if instance.ext_zone then + is_pick = is_pick and gui.pick_node(instance.ext_zone, action.x, action.y) + end + + if is_pick then if action.pressed then -- Can interact if start touch on the button instance.can_action = true @@ -172,4 +178,11 @@ function M.activate(instance, is_animate, callback) end end -return M +--- Set additional node, what need to be clicked on button click +-- Used, if need setup, what button can be clicked only in special zone +function M.set_ext_zone(instance, zone) + instance.ext_zone = helper.get_node(zone) +end + + +return M \ No newline at end of file