Page 1 of 1

Scaling and scaling xy values?

Posted: Fri Nov 13, 2020 6:55 pm
by Yachtturner
I know enough to be dangerous so far so please be kind! I have a project that i can scale the window to different scales by pressing the 123or 4 number. the graphics all scale but my mouseclicks are all at the original spots making everything off. Im not sure how to even go about this but how do I increase the window and all its components together?

i start with these window settings in the main love.load.

Any help would be greatly appreciated.

function love.load()

love.window.setMode(900, 600, {resizable=true, vsync=false, minwidth=400, minheight=300})
love.window.setPosition(300,100)
love.graphics.scale(SCALE,SCALE)
COREWIDTH = 600
COREHEIGHT =400
SCALE = 1

Re: Scaling and scaling xy values?

Posted: Sat Nov 14, 2020 4:40 am
by norubal
You have to *scale* mouse coordinates.

Code: Select all

function love.mousepressed(x, y)
    x = x * SCALE
    y = y * SCALE
    -- handle mousepressed events...
end

Re: Scaling and scaling xy values?

Posted: Sat Nov 14, 2020 6:44 am
by Yachtturner
thank you for the response. seems like I cant get that to work. mouse still is way off when scaled up. not sure what Im doing wrong.

Re: Scaling and scaling xy values?

Posted: Sat Nov 14, 2020 11:55 am
by ReFreezed
The default program loop (love.run) resets the coordinate system (with love.graphics.origin) each frame, so your love.graphics.scale() in love.load() doesn't actually affect any drawing operations. You should call love.graphics.scale() right before drawing, together with what norubal said.