Simple Question: Offset Camera (canvas?)

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
osoII
Prole
Posts: 9
Joined: Tue Jul 16, 2013 4:46 am

Simple Question: Offset Camera (canvas?)

Post 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.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Simple Question: Offset Camera (canvas?)

Post 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.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
osoII
Prole
Posts: 9
Joined: Tue Jul 16, 2013 4:46 am

Re: Simple Question: Offset Camera (canvas?)

Post 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.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Simple Question: Offset Camera (canvas?)

Post by davisdude »

No problem. You wouldn't believe how many 'wow I feel dumb now' moments I've had recently.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 91 guests