mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +00:00
Prevent base menus from extending beyond the boundaries of the application window
This commit is contained in:
parent
b49f5ceb61
commit
3265575d1e
@ -91,6 +91,20 @@ function newobject:update(dt)
|
||||
self.largest_item_width = 0
|
||||
self.largest_item_height = 0
|
||||
|
||||
local screen_width = love.graphics.getWidth()
|
||||
local screen_height = love.graphics.getHeight()
|
||||
local sx = self.x
|
||||
local sy = self.y
|
||||
local width = self.width
|
||||
local height = self.height
|
||||
local x1 = sx + width
|
||||
if sx + width > screen_width then
|
||||
self.x = screen_width - width
|
||||
end
|
||||
if sy + self.height > screen_height then
|
||||
self.y = screen_height - self.height
|
||||
end
|
||||
|
||||
if update then
|
||||
update(self, dt)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user