等距六边形瓷砖地图

问题描述 投票:0回答:0

我想用六边形而不是正方形创建一个等距图块地图,如图所示:

如何实现这一目标?我在正确定位瓷砖以及检测点击了哪个瓷砖时遇到问题。

简单地使用

IsometricTileMapComponent
六边形瓷砖会导致瓷砖不正确地重叠。

一个可能的解决方案是

extend
IsometricTileMapComponent
并覆盖适当的方法,主要(我认为)以下两个:

/// Get which block's surface is at isometric position [p].
///
/// This can be used to handle clicks or hovers.
/// This is the opposite of [getBlockCenterPosition].
Block getBlock(Vector2 p) {}

/// Get the position in which a block is rendered in, in the isometric space.
///
/// This does not include the (x,y) PositionComponent offset!
/// This assumes the tile sprite as a rectangular tile.
/// This is the opposite of [getBlockRenderedAt].
Vector2 getBlockRenderPosition(Block block) {}

但我不知道这些方法如何寻找六边形等距空间。 也许 this 文章可能会有所帮助,但我在计算正确的数学时遇到了问题。

flutter isometric flame
© www.soinside.com 2019 - 2024. All rights reserved.