kikito / gamera

A camera system for LÖVE

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support gravity and crop/fill for aspect mismatches

fluffy-critter opened this issue · comments

Gamera looks pretty great! But there's a use case it doesn't cover that I need, namely being able to specify a camera view based on any arbitrary aspect and having the screen preferentially cover a particular area of it. For example, the incredibly tedious scaling setup code in one of my games sets the screen up to prevent people from peeking ahead, and there's also obvious use cases for cropping the camera's view in case of a mismatch instead.

I would propose that there be an optional configuration stash that gets passed in as a fifth parameter, with options like:

gamera.new(0, 0, 100, 100, {
    fit = 'grow',
    anchor = {0.5, 1}
})

where fit can be one of (for example) grow, shrink, or stretch, and anchor would give the relative anchor point for the center (defaulting to {0.5,0.5}); so for example the above would crop the camera view to match the aspect with the center point being the center of the bottom edge; on a 16:9 screen your screen coordinates would map to (0,43.75)–(100,100), for example.

As another example, the camera setup for the code I linked to would be:

gamera.new(-960, -540, 1920, 1080, { fit = 'shrink', anchor = {0.5, 1} });

This looks very game-specific to me. My recommendation would be implementing a cameraman of sorts (some piece of code which abstracts the camera between your game and gamera) and putting those special restrictions there. For now I will close this issue. By the way, apologies for my delay in answering.