fixed buttons
This commit is contained in:
parent
cbf6754e24
commit
f82e12cfa0
1 changed files with 8 additions and 9 deletions
|
|
@ -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
|
||||
if self.lastPressed and not self.prevPressed then
|
||||
self:pressed()
|
||||
end
|
||||
elseif self.lastPressed and self.prevPressed then
|
||||
self:held( dt )
|
||||
elseif not self.lastPressed and self.prevPressed then
|
||||
self:released()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue