mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
V1 update (#1)
This commit is contained in:
committed by
Squishy (C6H12O6+NaCl+H2O)
parent
3343d8711b
commit
1d6643448e
@@ -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
|
||||
Reference in New Issue
Block a user