The h2d.Camera instance is now tracked via RenderContext.currentCamera variable. This allows for much more flexible camera visibility filtering other than top-level layer filtering, as objects nested deep in the object tree now will be able to check which camera they are being rendered by during drawRec call and alter/prevent rendering when needed.
Motivation: While filtering by top-level layers works reasonably well, when more complex cases arise, like camera-specific effects nested in the object tree or camera-specific parameters for rendering like tint or alpha - it becomes clear that a way to check current active camera is required.
Additionally updated Camera2D sample:
Fixed regression after Layers.add adding to top-most layer by default.
Added a moving car sprite that uses ctx.currentCamera to filter its visibility as an example of new feature.
The
h2d.Camera
instance is now tracked viaRenderContext.currentCamera
variable. This allows for much more flexible camera visibility filtering other than top-level layer filtering, as objects nested deep in the object tree now will be able to check which camera they are being rendered by duringdrawRec
call and alter/prevent rendering when needed.Motivation: While filtering by top-level layers works reasonably well, when more complex cases arise, like camera-specific effects nested in the object tree or camera-specific parameters for rendering like tint or alpha - it becomes clear that a way to check current active camera is required.
Additionally updated Camera2D sample:
Layers.add
adding to top-most layer by default.ctx.currentCamera
to filter its visibility as an example of new feature.