2

What is the game all about?

It's a puzzle game. I am using AndEngine to build it on Android platform (currently). I have divided the game into various World, with each World containing various Levels.

What is the Issue?

See the Game design below. The purpose of the game is to drag-and-drop the broken pieces into the "drop" area (a.k.a. holder) and form the circle. I've developed the basic 2 levels of the game. This is the third level. Where there are 3 pieces as different objects named 1,2,3. I've to drop all 3 pieces into the drop. The issue is how do I know that all the broken pieces have filled the holder? I'm using AndEngine for the first time and have very little idea how this can be done. Tapping on any broken object would rotate it by 90 degrees. So there can be 4 possible solutions for each of them).

Level3

Also, the logic should hold true for any shape, any number of broken pieces, any number of holders.

Ideas that I've thought about

We've thought to solve this using:

  1. Area of the holder is filled -> But how do we programmatically do that?
  2. Take center coordinates of each broken piece and find the distance from the center of the circle. Verify this in all the 4 conditions (all 4 rotations by 90 degree each). -> We're trying to figure this out.
  3. See if all the broken pieces are used in the holder area -> What if there are more than one holder?

Any technical help or any references would be really great.

4

3 回答 3

2

鉴于 3 个拼图“碎片”可以旋转 90 度,因此可以有四种解决方案。让这四种配置称为精灵可以拥有的四个“阶段”。所以我们为每个精灵有四个阶段。

尝试这个 :

1) 获取每个精灵的中间坐标(使用 converToLocalCoordinates() )。

2)制作一个表格,其中行为 Sprite 1 、 2 、 3 ,列具有阶段 1 、 2 、 3 、 4 。

3)这会给你12个坐标。

4) 填表,在找到每个精灵在不同阶段的解决方案中的中心坐标后。

5)你可以做一个“捕捉”功能,当精灵在特定阶段进入“持有人”时,然后根据上面的表格设置到适当的坐标。

6)为了更好地实现捕捉,在实现捕捉的答案坐标周围取一个范围。

7) 此外,如果一个精灵已经在支架内并且插入了另一个精灵,如果它们发生碰撞或者如果精灵不在“捕捉范围”内,则可以将精灵放回原来的位置。

8) 注意只有当棋子进入正确的状态时才会发生捕捉,这取决于第一个精灵被捕捉到支架的阶段。

于 2013-06-07T10:07:28.990 回答
1

您可以为此使用 mysql 和空间索引。然后你可以检查用户输入是否所有碎片一起组成一个圆圈?这是检查多边形内多边形的链接:检查多边形是否在多边形内

于 2013-06-07T05:04:21.283 回答
0

如果所有的碎片都旋转了 90 度,那么每个谜题都有四种“不同”的解决方案,对吧?

我不确定技术实现,但也许可以按像素计算面积?您必须计算非透明像素而不是使用边界框(假设为 .png 精灵)。

但是,您根据与圆心的接近程度进行计算的想法并不难实现。根据精灵边界框的大小获得一种解决方案的 (x,y) 后,您可以根据需要添加和减去圆的半径(以像素为单位)。您只需要知道棋子的锚点位于圆的哪个象限。

我希望这些想法有所帮助。

于 2013-06-07T05:17:02.330 回答