1

我正在尝试制作一个黑屏游戏,当您滑动屏幕时,您触摸的黑色部分会消失并在其后面显示图像。目的是保持滑动,直到你能猜出图像是什么。

我见过其他应用程序可以做到这一点。我被困在如何做到这一点上。我的想法是通过更改像素来修改位图以透视。但是我看不到任何访问位图内存的方法,或者也许还有另一种方法可以做到这一点????

4

3 回答 3

2

One way to make this would be having your bitmap drawn like any other image, and on top of it you'll have an editable black bitmap (that you can dinamically make using draw(), look for documentation on Paint class), and when the user swipes, you record the path, and use a brush to paint transparent pixels on the black bitmap, so the image below will become visible.

That last part is almost the same as implementing a simple paint app, so it shouldn't be hard to figure out.

于 2012-10-20T00:20:31.910 回答
1

一个潜在的解决方案是使用该copy方法创建图像位图的副本。这样您就可以对图像进行修改。

然后用黑色方块遮住图像。当用户在图像上擦拭手指时,您需要记录他们遵循的路径并以此为基础创建遮罩图像。使用该蒙版,您可以浏览原始图像并仅在滑动路径未覆盖的区域中将图像涂黑。

这可能值得一试Paint

于 2012-10-20T00:17:09.360 回答
0

您可以使用 a ViewPager,但我怀疑这不是您想要的滑动效果类型。然而,这是一种简单的实现方式。ViewPager在股票 android 应用程序中广泛使用。看看 Play Music 如何让您在最近/专辑/...视图之间滑动。正如您所看到的,它更像是一种分页(相对于滑动)效果。

您可以使用ImageSwitcher, 并为输入/输出效果添加动画。这是一篇关于如何在动画中使用它的 SO 文章,

设置动画 ImageSwitcher 将运行(in_left 或 out_right)

然而,这并不好用,因为动画是在检测到滑动后触发的……动画不跟随滑动。

如果你不喜欢这些,你可能会坚持编写一些 OpenGL 代码来获得你想要的东西。

于 2012-10-19T23:59:24.103 回答