flameforge2d

Flame camera.moveTo - render objects off the game canvas


When moving the camera, the BodyComponents gets rendered off the game area, do you know why or is it a bug?

enter image description here

Flutter:

child: Scaffold(
  body: SafeArea(
    child: Column(
      children: [
        const Text("data"),
        Container(
          color: Colors.blue,
          alignment: Alignment.bottomCenter,
          child: SizedBox(
            width: 300,
            height: 600,
            child: Stack(
              children: [
                GameWidget<BallsSampleForge2DGame>(
                    game: BallsSampleForge2DGame(),

Flame:

camera.moveTo(<some vector>)

Solution

  • The GameWidget is not clipped by default. You can either use a FixedResolutionViewport which automatically clips the canvas, or you can wrap the GameWidget in Flutter's ClipRect widget.

    https://api.flutter.dev/flutter/widgets/ClipRect-class.html