How does scaling work?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
MightyPancake
Prole
Posts: 26
Joined: Thu Feb 14, 2019 7:45 pm

How does scaling work?

Post by MightyPancake »

Hello, I'm here with yet another stupid (or not) question. I'm wondering, if everything we do in LÖVE (at least in .graphic) is in pixels, how does the game scale. I mean, aren't there any problems with it? For example, if I create game that uses a 1920×1080 (FHD) image as background will it scale automatically on other devices to be displayed? How will it be displayed on device that has smaller or bigger resolution? Won't it just look too tiny/big? Or do I have to somehow use scale function for that? Anyone knows how it works?
User avatar
keharriso
Citizen
Posts: 92
Joined: Fri Nov 16, 2012 9:34 pm

Re: How does scaling work?

Post by keharriso »

LÖVE displays a window with the resolution you give it in conf.lua or love.window.setMode. This is the space you have to work with. Next, your images/sprites/animations also have a resolution. LÖVE will not, by default, scale your images for you. With your background example, if your game window is 800x600 and your image is 1920x1080, you'll need to use the sx/sy parameters to love.graphics.draw. Something like this:

Code: Select all

love.graphics.draw(background, 0, 0, 0, 800/1920, 600/1080)
You've probably already figured this out. It can be generalized to work for any image and desired screen size.
LÖVE-Nuklear - a lightweight immediate mode GUI for LÖVE games
MightyPancake
Prole
Posts: 26
Joined: Thu Feb 14, 2019 7:45 pm

Re: How does scaling work?

Post by MightyPancake »

keharriso wrote: Tue Feb 19, 2019 7:39 pm LÖVE displays a window with the resolution you give it in conf.lua or love.window.setMode. This is the space you have to work with. Next, your images/sprites/animations also have a resolution. LÖVE will not, by default, scale your images for you. With your background example, if your game window is 800x600 and your image is 1920x1080, you'll need to use the sx/sy parameters to love.graphics.draw. Something like this:

Code: Select all

love.graphics.draw(background, 0, 0, 0, 800/1920, 600/1080)
You've probably already figured this out. It can be generalized to work for any image and desired screen size.
Thanks God You exist! Once again, fast and great response for my question. That's exactly what I needed! ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 48 guests