Page 1 of 1

Simple Question: Offset Camera (canvas?)

Posted: Wed Aug 21, 2013 2:58 am
by osoII
I'm trying to create a game where the playing field takes up a square in the right of the screen. I want to use a camera to zoom in and out, but the playing field isn't centered in the screen. Do I have to use canvases for this? I'm trying to avoid that, but if it's the simplest most efficient way then I can live with it.

Re: Simple Question: Offset Camera (canvas?)

Posted: Wed Aug 21, 2013 3:01 am
by davisdude
You don't have to use canvases for this. You can do one of two things: look for a camera lib. or make your own. If you want to make your own you will have to have this code:

Code: Select all

love.graphics.draw()
    love.graphics.push()
    
    whatever()

    love.graphics.pop()
end
Look at the `coordinate System` section of the love.graphics.wiki for more info.

Re: Simple Question: Offset Camera (canvas?)

Posted: Wed Aug 21, 2013 3:29 am
by osoII
Well, now I feel dumb. I was using the HUMP camera, I just added love.graphics.translate before drawing with the camera and presto. Thanks.

Re: Simple Question: Offset Camera (canvas?)

Posted: Wed Aug 21, 2013 3:40 am
by davisdude
No problem. You wouldn't believe how many 'wow I feel dumb now' moments I've had recently.