【发布时间】:2022-10-22 00:11:37
【问题描述】:
从示例中使用的createBoundaries,我了解了如何创建“墙”/EdgeShape。
移动相机时,我会画线。杜你知道如何不画这些线或使它们透明 - 看过FixtureDef?
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);
}
}
【问题讨论】: