Prevent base menus from extending beyond the boundaries of the application window

This commit is contained in:
Kenny Shields 2014-01-26 05:40:08 -05:00
parent b49f5ceb61
commit 3265575d1e

View File

@ -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