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 )
|
function Button:checkPoint( point )
|
||||||
local px, py = point:coords()
|
local px, py = point:coords()
|
||||||
local sx, sy = self.position:coords()
|
local sx, sy = self.position:coords()
|
||||||
local ex, ey = self.position:coords()
|
local ex, ey = self.size:coords()
|
||||||
ex = ex + sx
|
ex = ex + sx
|
||||||
ey = ey + sy
|
ey = ey + sy
|
||||||
return px >= sx and px <= ex and py >= sy and py <= ey
|
return px >= sx and px <= ex and py >= sy and py <= ey
|
||||||
|
|
@ -69,15 +69,14 @@ end
|
||||||
function Button:update( dt, point, pressed )
|
function Button:update( dt, point, pressed )
|
||||||
self.prevPressed = self.lastPressed
|
self.prevPressed = self.lastPressed
|
||||||
self.lastPressed = pressed
|
self.lastPressed = pressed
|
||||||
|
|
||||||
if self.lastPressed and not self.prevPressed then
|
|
||||||
local inBounds = self:checkPoint( point )
|
local inBounds = self:checkPoint( point )
|
||||||
if inBounds then
|
if inBounds then
|
||||||
|
if self.lastPressed and not self.prevPressed then
|
||||||
self:pressed()
|
self:pressed()
|
||||||
end
|
|
||||||
elseif self.lastPressed and self.prevPressed then
|
elseif self.lastPressed and self.prevPressed then
|
||||||
self:held( dt )
|
self:held( dt )
|
||||||
elseif not self.lastPressed and self.prevPressed then
|
elseif not self.lastPressed and self.prevPressed then
|
||||||
self:released()
|
self:released()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue