Removed hardcoded screen width in VBox class.

This commit is contained in:
2025-10-05 23:34:52 -04:00
parent 2dea06f8c7
commit 719a9cd0f6
2 changed files with 5 additions and 3 deletions

View File

@@ -37,7 +37,7 @@ function MainMenu:_init(name, index)
self.title_font = Font('fonts/BBrick.ttf', 35)
-- Create UI elements.
self.btns = VBox(15, 5)
self.btns = VBox(15, 5, love.graphics.getWidth())
self.btns:add_label('LoveDOS', self.title_font, Color(215, 0, 0), true)
self.btns:add_text_button('New Game', self.btn_font)
self.btns:add_text_button('Load Game', self.btn_font)

View File

@@ -20,9 +20,11 @@ local VBox = make_class(Drawable, Asset)
-- Class methods
------------------------------------------------------------------------------
function VBox:_init(x, y, spacing)
function VBox:_init(x, y, w, h, spacing)
self.x = x ~= nil and x or 0
self.y = y ~= nil and y or 0
self.w = w ~= nil and w or 0
self.h = h ~= nil and h or 0
self.s = spacing ~= nil and spacing or 10
self.elements = {}
end
@@ -48,7 +50,7 @@ function VBox:load()
end
if v.float_right then
v.x = 320 - self.x - v.w
v.x = self.w - self.x - v.w
else
v.x = self.x
end