在摄像机移动时,瓷砖之间的垂直线。

huangapple go评论54阅读模式
英文:

Vertical lines between tiles when camera is moving

问题

我正在尝试使用Flame构建一个由方形瓷砖构建的简单横向卷轴游戏。

    @override
    Future<void> onLoad() async {
      final orange = Paint()..color = Color(0xFFFF9000);
      final double tileSize = 64;
      for (var i = 0; i <= 100; i++) {
        add(RectangleComponent(position: Vector2(i * tileSize, 100), size: Vector2.all(tileSize), paint: orange));
      }
    }

当屏幕静止时,一切都按预期工作。然而,当我添加相机移动时,在瓷砖之间出现垂直线。

    @override
    void update(double dt) {
      camera.moveTo(Vector2(camera.position.x + 1, 0));
      super.update(dt);
    }

我怀疑这可能与Flutter抗锯齿错误有关。是否有人知道是否有解决方法?谢谢!

英文:

I'm trying to build a simple side-scroller game with a level built of square tiles using Flame.

@override
Future&lt;void&gt; onLoad() async {
  final orange = Paint()..color = Color(0xFFFF9000);
  final double tileSize = 64;
  for (var i = 0; i &lt;= 100; i++) {
    add(RectangleComponent(position: Vector2(i * tileSize, 100), size: Vector2.all(tileSize), paint: orange));
  }
}

在摄像机移动时,瓷砖之间的垂直线。

When the screen is static, everything works as expected. However, when I add camera movement, I see vertical lines between the tiles.

@override
void update(double dt) {
  camera.moveTo((Vector2(camera.position.x + 1, 0)));
  super.update(dt);
}

在摄像机移动时,瓷砖之间的垂直线。

I suspect it might be something to do with Flutter antialiasing bug. Does anybody know if there's a workaround? Thanks!

答案1

得分: 1

这确实是那个 bug,我们也在一些问题中有记录(例如这个 https://github.com/flame-engine/flame/issues/1888
如果可能的话,你可以尝试使用 Impeller,这个 bug 不应该存在。

其他解决方法包括在瓦片重叠的地方绘制相同的颜色,当然这并不总是可行的。另一个选项是使用只在完整像素中移动的摄像头,以避免舍入误差。

英文:

This is indeed that bug, we have it documented on a few of our issues too (like this one for example https://github.com/flame-engine/flame/issues/1888)
You can try to use Impeller if that is an option for you, where this bug shouldn't be present.

Other workarounds would be to draw the same color underneath the tiles where they are overlapping, that is of course not always possible though.
And the other option is to use a camera that only moves in full pixels, so that there are no rounding errors.

huangapple
  • 本文由 发表于 2023年2月6日 06:01:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75355820.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定