Scaling and scaling xy values?

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
Yachtturner
Prole
Posts: 2
Joined: Fri Nov 13, 2020 6:51 pm

Scaling and scaling xy values?

Post 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
Chris Turner
User avatar
norubal
Party member
Posts: 137
Joined: Tue Jan 15, 2013 5:55 am

Re: Scaling and scaling xy values?

Post 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
Yachtturner
Prole
Posts: 2
Joined: Fri Nov 13, 2020 6:51 pm

Re: Scaling and scaling xy values?

Post 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.
Chris Turner
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Scaling and scaling xy values?

Post 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.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests