Dynamic Scaling?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Dynamic Scaling?
Hi all. I'm trying to scale a title screen (text element within Gspot) dynamically to any resolution. Basically I want to start drawing the text 1/4 from the left side of the window and stop drawing 1/4 distance from the right side of the window, and have it perfectly centered and scaled no matter the (widescreen) resolution selected. So far this has just been driving me crazy. No amount of Googling or searching these forums (which are HUGE) have yielded an answer.
Re: Dynamic Scaling?
Code: Select all
local w,h = love.graphics.getDimensions()
love.graphics.printf(text, w/4, h/2, w/2, "center")
Re: Dynamic Scaling?
Hmm how does that translate to Gspot button elements? Here's the code I have now:
As you can see there's no easy parameter for centering, so I have to do it manually.
Edit: It looks like push is exactly what I needed! Thank you so much!
Code: Select all
if love._version_major == 0 and love._version_minor < 9 then
error("This library needs love2d 0.9.0 or above")
end
gui = require "gspot"
local tw, th = love.graphics.getDimensions()
font =
{
name = "font/mainmenu_title.ttf",
size = (tw - th) / 2 -- need to figure out how to scale font size appropriately
}
function love.load()
local button = gui:button("Test", {x = (tw / 4), y = gui.style.unit, w = font.size, h = gui.style.unit}, nil, true)
button:setfont(font.name, font.size)
button.click = function(this, x, y)
gui:feedback("Button works!")
end
end
function love.update(dt)
gui:update(dt)
end
function love.draw()
gui:draw()
end
function love.mousepressed(x, y, button)
gui:mousepress(x, y, button)
end
function love.mousereleased(x, y, button)
gui:mouserelease(x, y, button)
end
function love.wheelmoved(x, y)
gui:mousewheel(x, y)
end
Edit: It looks like push is exactly what I needed! Thank you so much!
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests