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?
Current project: https://togfox.itch.io/hwarang
A card game that brings sword fighting to life. Simple to learn, hard to master. Learn when to advance, dodge, strike and counter. Learn how to strike without being struck. https://discord.gg/HeHgwE5nsZ
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.
I wanted the screen to be small in launch (a small main menu) so love.load sets it small.
After a button is clicked, I want to make it larger, but not full screen.
Doing a resize inside love.update seems to be the wrong way to do this.
Current project: https://togfox.itch.io/hwarang
A card game that brings sword fighting to life. Simple to learn, hard to master. Learn when to advance, dodge, strike and counter. Learn how to strike without being struck. https://discord.gg/HeHgwE5nsZ
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.
Hmmm. So you're suggesting I'm pushing too many parameters on the resize?
I'll try that. Thanks!
Current project: https://togfox.itch.io/hwarang
A card game that brings sword fighting to life. Simple to learn, hard to master. Learn when to advance, dodge, strike and counter. Learn how to strike without being struck. https://discord.gg/HeHgwE5nsZ
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.
Yes. I see. I need a condition around the update so it resizes just the once. Thanks.
Current project: https://togfox.itch.io/hwarang
A card game that brings sword fighting to life. Simple to learn, hard to master. Learn when to advance, dodge, strike and counter. Learn how to strike without being struck. https://discord.gg/HeHgwE5nsZ