V1 update (#1)

This commit is contained in:
Nguyễn Quốc Hưng
2024-06-06 16:01:24 +07:00
committed by Squishy (C6H12O6+NaCl+H2O)
parent 3343d8711b
commit 1d6643448e
30 changed files with 1000 additions and 228 deletions

View File

@@ -139,11 +139,11 @@ function button:isHovering(x,y)
end
---Trigger press action, only when ``self._hovering`` is true
function button:press(x, y, touchID)
if (touchID and self:isHovering(x, y) or self._hovering) and not self._pressed then
self.codeWhenPressed()
if self:isHovering(x, y) and not self._pressed then
self._touchID = touchID
self._pressed = true
self.codeWhenPressed()
self:draw()
return true
@@ -154,7 +154,7 @@ function button:release(x, y, touchID)
local valid = true
if touchID then
valid = touchID == self._touchID
elseif x and y then
else
valid = true
end
@@ -311,4 +311,13 @@ function BUTTON.release(list, x, y, touchID)
for _, v in pairs(list) do if v:release(x, y, touchID) then return true end end
end
--- Do a reset, useful for switching scenes
function BUTTON.reset(list)
for _, v in pairs(list) do
v._pressed = false
v._hovering = false
v._touchID = false
end
end
return BUTTON