okamstudio/godot — pull request #11 by rafalcieslak (2014-02-10 13:41:45+00:00)
Title: A rotating Camera2D

These changes add a new Camera2D.Rotating property. By default this setting is off, and such default behaviour is exactly the same as before these changes.

When on, the camera will follow it's global rotation, so that one can change its orientation if desired.
In some cases rotating the camera makes not much sense, for example when it is a child of a movable character in a side-scrolling platform game - it should follow that character, but never rotate, so that game's top is always camera's top.

However, there is a number of cases when we would like to rotate the view.
- Any kind of 2D top-down games, where the player sees the surroundings from above, like a flat map - in such case the camera should follow character's orientation, so that screen's top is the character's front. For example, top-down driving/racing game's controls are much less confusing when if the camera rotates [to enable view from vehicle's perspective one might simply reparent the camera to the vehicle node, and enable Centered and Rotating properties.].
- Some animations/effect may include a wiggling camera.
- Games with perspective changes, (where e.g. one can change gravity orientation) may want to rotate the camera instead of rotating the whole world, as this approach is simpler and probably more efficient.

The way I have implemented this feature makes it fully compatible with other camera properties, including Camera2D.Centered, Camera2D.Zoom, Camera2D.Offset, drag margin, etc.

It does not break existing scenes, as it is an optional feature that is turned off by default.

I have tested it in a number of different use cases [following cam, dragged cam, static camera, multiple cameras and animated camera movement], with desired results, but if you notice anything wrong, I will be happy to fix it.