render method

  1. @override
void render(
  1. Canvas canvas
)
override

Implementation

@override
void render(Canvas canvas) {
  super.render(canvas);
  if (!_containColor) return;
  Vector2 size = gameRef.camera.canvasSize;
  canvas.saveLayer(Offset.zero & Size(size.x, size.y), Paint());
  canvas.drawColor(color!, BlendMode.dstATop);
  _visibleLight.forEach((light) {
    final config = light.lightingConfig;
    if (config == null || !light.lightingEnabled) return;
    config.update(_dtUpdate);
    canvas.save();

    canvas.scale(gameRef.camera.zoom);
    canvas.translate(
      -(gameRef.camera.position.x),
      -(gameRef.camera.position.y),
    );

    if (config.type is CircleLightingType) {
      _drawCircle(canvas, light);
    }

    if (config.type is ArcLightingType) {
      _drawArc(canvas, light);
    }
    canvas.restore();
  });
  canvas.restore();
}