function love.load
void = love.window.setMode(someWidthvalue, someHeightvalue)
end
function love.update
void = love.window.updateMode(newWidthvalue,newHeightvalue)
end
The love.update causes endless flashing as the window redraws. If this is not the correct way to resize a window then is there a better way?
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
So, what you're talking about is a simple resolution toggle while the game is running? Simply check for when the specified button/menu item is clicked, and only then change the resolution.
local resolutionMultiplier = 1
local resolutionMultiplierMax = 4
local baseWindowWidth = 100
local baseWindowHeight = 100
function love.load ()
-- initialize window size to whatever the resolution multiplier is at launch
love.window.setMode(baseWindowWidth * resolutionMultiplier, baseWindowHeight * resolutionMultiplier)
end
function love.update (dt)
-- check if menu item or button has been pressed
if resolutionToggleButtonHasBeenClicked() then
resolutionMultiplier = resolutionMultiplier + 1
if resolutionMultiplier > resolutionMultiplierMax then
resolutionMultiplier = 1
end
-- set the resolution
love.window.updateMode(baseWindowWidth * resolutionMultiplier, baseWindowHeight * resolutionMultiplier)
end
end
How you go about implementing the actual toggle check (the "resolutionToggleButtonHasBeenClicked" function) is up to you. Could simply check if a specific keyboard button has been pressed in love.keypressed callback, or some other manner if you want to do it via a pause or configuration menu.
No? The issue in your original post is that you're updating the window mode every time love.update runs, which causes the window to resize/update every single frame. This is not at all a good idea.
You should only ever mess with the window dimensions when you actually mean it. In practice this often means only do something when the user of your application/game is explicitly pressing or toggling something, or maybe even resizing the window manually by dragging its edges. As such, it has nothing to do with the number of parameters you are passing to love.window.updateMode, but the frequency.