flixel icon indicating copy to clipboard operation
flixel copied to clipboard

Consider separating concepts of screen from camera

Open JoeCreates opened this issue 11 years ago • 4 comments
trafficstars

Presently, FlxCamera represents both the position at which a world is being observed (FlxCamera.scroll x/y) and the rectangular screen on which the world is drawn. It might be worth considering splitting these up, having both a FlxScreen and FlxCamera.

The obvious drawback is that it adds a little more complexity, although in practice most of this complexity would be hidden.

Benefits would include:-

  • Easily swap cameras while maintaining screen size and position, as cameras are simply attached to a screen.
  • View the same camera from different screens.
  • Camera position would actually be the camera position (more intuitive than having a "scroll" position
  • Encourage better implementations of existing features such as shake and zoom, which currently manipulate the entire screen position and size, whereas it would be better to implement these in terms of the screens view of the world.

I think most stuff you already do with FlxG.camera(s) would stay the same. There would need to be some way of tracking the screens, though.

Additional considerations:-

  • Screen would have to be responsible for actually using some properties of the camera, such as the cameras bounds, as the effect is dependent on the size of the screen.
  • Attach multiple cameras to the same screen? Possibly useful for HUD layers?

JoeCreates avatar May 11 '14 15:05 JoeCreates

It definitely simplifies stuff for shaders too.

Ohmnivore avatar May 11 '14 17:05 Ohmnivore

This is a good idea, but a lot of work. Careful testing would be required before a merge is considered.

gamedevsam avatar May 11 '14 18:05 gamedevsam

Definitely an idea worth investigating.

Gama11 avatar May 11 '14 21:05 Gama11

I like this idea. Had some confusion myself how to move the camera directly without using focusOn(), and the camera.scroll docs mentioned parallax etc, which made me disregard it. (still new to HaxeFlixel)

A short term change could be swapping the properties, camera.x/y being the focus point, and adding the screen itself like camera.screen.x/y. I know this wouldn't be as fancy as the suggested solution, but might clear up some confusion and be more intuitive. And I suppose the screen itself is less often manipulated directly, unless you're doing something special.

gebba avatar Jul 10 '14 13:07 gebba