Page 1 of 1

Problem with In-Game Zooming [SOLVED]

Posted: Mon Mar 14, 2011 7:25 pm
by Archiboldian C.
I've recently been trying to make a game which involves a planet and the simulated inhabitance there-of, and have had some troubles with using love.graphics.scale to zoom in and out with the middle scroller mouse button thing.
I have it changing a variable up or down depending on which way you scroll and I have it zooming in an out, but I can't figure out how to stop love.graphics.scale from scaling everything else after the planet and it's inhabitants, so the mouse (which obviously has to go over everything) is scaled with the rest of it.

I tried doing

Code: Select all

love.graphics.scale(1)
to set the graphics' scale back to normal before it draws the mouse but that didn't do anything.

I'm welcome to any alternatives to love.graphics.scale and some help with layering different things in the same way you can layer movieclips in flash.
I had a look into framebuffers but got a bit confused due to the lack of examples on the wiki.
Here's the perpetrator:

Code: Select all

if area == "ingame" then
	love.graphics.scale(scale)
	love.graphics.setColor(51, 204, 102, 255)
	love.graphics.setBlendMode("alpha")
	love.graphics.setColorMode("modulate")
	love.graphics.circle("fill", 640, 400, 500, 500)
end

love.graphics.scale(1)
love.graphics.draw(p, 0, 0)
Thanks :crazy:
J

Re: Problem with In-Game Zooming

Posted: Mon Mar 14, 2011 7:37 pm
by EmmanuelOga
The reason is that love.graphics.scale operates in the current scale. So if you first scaled everything up 2x, then you'll need to scale down 0.5 to get back to normal. An even better method is pushing and popping the scale/translation settings. Something like:

Code: Select all

  love.graphics.push() -- saves current state
  love.graphics.scale(scale) -- scales everything
  renderScaledStuff()
  love.graphics.pop() -- restores original scale   
  renderNormalStuff()
The nice thing is that you can push and pop as many times as you want.

Re: Problem with In-Game Zooming

Posted: Mon Mar 14, 2011 8:00 pm
by Archiboldian C.
Bloody frigging excellent. :o
Thank you