Search code examples
flutterflame

Make fixture(shape) transparent when drawing walls


From createBoundaries used in examples, I see how to create "Walls"/EdgeShape.

When moving the camera I get lines drawn. Du you know how to not draw these lines or make them transparent - looked in the FixtureDef?

enter image description here

import 'package:flame_forge2d/flame_forge2d.dart';

class Wall extends BodyComponent {
  final Vector2 start;
  final Vector2 end;

  Wall(this.start, this.end);

  @override
  Body createBody() {
    final shape = EdgeShape()..set(start, end);

    final fixtureDef = FixtureDef(shape)
      ..restitution = 0.0
      ..friction = 0.3;

    final bodyDef = BodyDef()
      ..userData = this // To be able to determine object in collision
      ..position = Vector2.zero()
      ..type = BodyType.static;

    return world.createBody(bodyDef)..createFixture(fixtureDef);
  }
}

Solution

  • Set renderBody = false or override render to be empty in the BodyComponent, Wall in this case.