I’m afraid there is no example like this. I’m working on a camera handling module for 2D/2.5D games and such thing like this is possible, but I’m not yet ready for a release
Few tips:
I believe Defold built-in camera component is now perfect to use in 2/2.5D games
As mentioned earlier, I have a separate form my player game object (operator
) with another nested game object (offset
) with camera component:
Camera component has cool properties that you can set, e.g. you can use perspective (I’m using perspective for “free” parallax effect) or orthographic, explained the best in here:
My camera module is following all objects (or none) defined in actors table, as you can see I have separation of following on x and y axis:
The idea of not following when jumping is either by manually in your code changing these properties, so that it is not following hero, when jumping and following again, when landing, etc, but you also have to take into account some deadzone - when hero is outside of this deadzone, you should start following it anyway, in order not to allow it to escape the screen. Adjusting parameters might be difficult
Dead zone can be defined either around player’s position or camera’s position.
Finally with modifying the position of the offset
game object you can “lean” the camera in the direction of movement, zoom in/out or shake it (translational and rotational)!
Everything is just plain code executed in update
with all the data you need (actors positions, camera, operator and offet settings)