英文:
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<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));
}
}
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论