#49 add on_mouse_hover to hover component

This commit is contained in:
Insality
2020-05-04 01:12:25 +03:00
parent 75a1369997
commit 0cc848b53f
5 changed files with 52 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ local M = {}
M["button"] = {
HOVER_SCALE = vmath.vector3(0.02, 0.02, 1),
HOVER_MOUSE_SCALE = vmath.vector3(0.01, 0.01, 1),
HOVER_TIME = 0.04,
SCALE_CHANGE = vmath.vector3(0.035, 0.035, 1),
BTN_SOUND = "click",
@@ -23,6 +24,13 @@ M["button"] = {
anims.hover_scale(self, target_scale, M.button.HOVER_TIME)
end,
on_mouse_hover = function(self, node, state)
local scale_to = self.start_scale + M.button.HOVER_MOUSE_SCALE
local target_scale = state and scale_to or self.start_scale
anims.hover_scale(self, target_scale, M.button.HOVER_TIME)
end,
on_click = function(self, node)
local scale_to = self.start_scale + M.button.SCALE_CHANGE
anims.tap_scale_animation(self, node, scale_to)