My code:
Code: Select all
local objects = {
{x = g_x + 0, y = g_y, w = 50, h = 50},
{x = g_x + 55, y = g_y, w = 50, h = 50},
{x = g_x + 110, y = g_y, w = 50, h = 50},
{x = g_x + 165, y = g_y, w = 50, h = 50},
{x = g_x + 220, y = g_y, w = 50, h = 50}
}
function love.load()
love.window.setMode(800, 600, {resizable=true, vsync=false, minwidth=400, minheight=300})
local n = {x = love.graphics.getWidth() / 2 - 25,y = love.graphics.getHeight() / 2 - 25,w = 50,h = 50}
table.insert(objects, n)
end
local default_w = love.graphics.getWidth()
local default_h = love.graphics.getHeight()
function love.draw()
for i = 1, #objects do
local obj = objects[i]
love.graphics.setColor(42, 42, 42)
love.graphics.rectangle("fill", obj.x, obj.y, obj.w, obj.h)
end
end
function love.resize( new_w, new_h )
local scale_Width = new_w / default_w
local scale_Height = new_h / default_h
for i = 1, #objects do
local obj = objects[i]
obj.x = obj.x * scale_Width
obj.y = obj.y * scale_Height
obj.w = obj.w * scale_Width
obj.h = obj.h * scale_Height
end
default_w = new_w
default_h = new_h
end
Example of problem : https://love2d.org/imgmirrur/MIIbkGW.png
What i want make : https://love2d.org/imgmirrur/2la4Bye.png - Blue rects was save original proportionals is what i want make but currently in my case white rects is stretched like in second screenshot.
Ok so, if you don't want help me with code, give me any examples with the same, because i not found any information with that problem.