From f82e12cfa01c81746131d6e08e968419ebb3ff87 Mon Sep 17 00:00:00 2001 From: 2ndbeam <2ndbeam@disroot.org> Date: Wed, 22 Oct 2025 13:44:56 +0300 Subject: [PATCH] fixed buttons --- button.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/button.lua b/button.lua index eecb798..8b56a21 100644 --- a/button.lua +++ b/button.lua @@ -57,7 +57,7 @@ end function Button:checkPoint( point ) local px, py = point:coords() local sx, sy = self.position:coords() - local ex, ey = self.position:coords() + local ex, ey = self.size:coords() ex = ex + sx ey = ey + sy return px >= sx and px <= ex and py >= sy and py <= ey @@ -69,15 +69,14 @@ end function Button:update( dt, point, pressed ) self.prevPressed = self.lastPressed self.lastPressed = pressed - - if self.lastPressed and not self.prevPressed then - local inBounds = self:checkPoint( point ) - if inBounds then + local inBounds = self:checkPoint( point ) + if inBounds then + if self.lastPressed and not self.prevPressed then self:pressed() + elseif self.lastPressed and self.prevPressed then + self:held( dt ) + elseif not self.lastPressed and self.prevPressed then + self:released() end - elseif self.lastPressed and self.prevPressed then - self:held( dt ) - elseif not self.lastPressed and self.prevPressed then - self:released() end end