renderComponent method

void renderComponent(
  1. Canvas canvas,
  2. Component c
)

This renders a single component obeying BaseGame rules.

It translates the camera unless hud, call the render method and restore the canvas. This makes sure the canvas is not messed up by one component and all components render independently.

Implementation

void renderComponent(Canvas canvas, Component c) {
  if (!c.loaded()) {
    return;
  }
  if (!c.isHud()) {
    canvas.translate(-camera.x, -camera.y);
  }
  c.render(canvas);
  canvas.restore();
  canvas.save();
}