How does scaling work?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 26
- Joined: Thu Feb 14, 2019 7:45 pm
How does scaling work?
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?
Re: How does scaling work?
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:
You've probably already figured this out. It can be generalized to work for any image and desired screen size.
Code: Select all
love.graphics.draw(background, 0, 0, 0, 800/1920, 600/1080)
LÖVE-Nuklear - a lightweight immediate mode GUI for LÖVE games
-
- Prole
- Posts: 26
- Joined: Thu Feb 14, 2019 7:45 pm
Re: How does scaling work?
Thanks God You exist! Once again, fast and great response for my question. That's exactly what I needed!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:
You've probably already figured this out. It can be generalized to work for any image and desired screen size.Code: Select all
love.graphics.draw(background, 0, 0, 0, 800/1920, 600/1080)
Who is online
Users browsing this forum: Google [Bot] and 221 guests