我该怎么做?(Android Whack-A-Mole)

时间:2012-04-05 03:00:09

标签: android xml animation selector drawable

我正在制作一个简单的whack-a-mole游戏作为我的第一个用于Android的迷你项目。我不知道该如何解决这个问题。我知道设置所有内容的基本知识,但我不知道如何设置痣的动画并使其成为当鼹鼠处于向上位置时它可以被轻敲并且将计算一个点。我知道我可以做一个图像按钮并且计数器上升(计数器++)但是我需要能够将帧中的痣切换到向上位置的痣。我被告知使用一种叫做选择器或某种xml动画的drawable,但我不太明白该怎么做。如果有人能给我一些例子我会感激,或者如果有人能指出我正确的方向。谢谢!

2 个答案:

答案 0 :(得分:1)

使用游戏引擎。两个最受欢迎的(在我看来)引擎是AndEngineLibGDX。前者更倾向于初学者,是一个完整的引擎,而后者更像是中级到高级开发人员的框架。

答案 1 :(得分:0)

我之前创造了一个简单的鼹鼠游戏。我会用子弹格式写这个以便于查看:

- First, you have to set a 3 cols and 4 rows table (depends on you).
- Place a picture of a hole in every cell, a total of 12 images.
- You have to place those images in an array.
- The logic is to create a timer and for every tick there's a for loop that reads the array.
- In each array, there's a random boolean generator.
- If it is true, change the picture in that array to a hole with a mole appearing
- If it is false, change the picture to a hole without a mole
- To sum it all up: Every tick, it will loop all the picture(array) and randomize each whether it's true or false. Depending on the value, the picture changes.