Android 中制作动画的推荐方式
我在网上搜索了有关在 Android 中为角色设置动画的更多信息,但并没有完全理解它。我在这里问也许你可以给我一些关于如何以最好的方式做到这一点的建议或提示。
场景
想象 5 个绘制的角色(假设有 5 个人头)。我需要让它们动起来。我所说的动画是指让眼睛眨动、微笑、大笑等。现在我正在努力为每个动画制作位图资源。例如,对于眨眼动画,基本上我有 3 个图像,一张睁着眼睛,一张半闭着眼睛,一张闭着眼睛。我需要为角色设置动画才能使用所有这 3 个图像。
这就是我需要的所有动画,没有比这更奇特的了。有什么建议从哪里开始吗?
I've searched around the web to learn more about animating a character in Android but didn't fully understood it. I ask here maybe you could give me some advices or hints on how to make it in the best possible way.
Scenario
Imagine 5 drawn characters (let's say 5 human heads). I need to animate them. By animation I mean make eyes blink, smile, laugh etc. Right now I am working on making bitmap resources on each animation. For example for the blink animation, basically I have 3 images, one with eyes open, one with eyes half closed, one with eyes closed. I need to animate the character to use all these 3 images.
This is all the animation I need, nothing more fancier. Any suggestions from where to start ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用这种类型的 xml 添加可绘制对象
,为您的序列动画设置不同的图像。将此可绘制对象设置为 imageview 中的背景
add drawable using this type of xml
here set different images for your sequence animation.set this drawable as your background in imageview
为了让您开始,您可以尝试帧动画,它是 Android 中基本动画包的一部分,官方文档网站上有一个相对简单的示例:http://developer.android.com/guide/topics/resources/animation-resource.html#Frame。
如果您需要对动画进行更多控制,则需要考虑使用 SurfaceView 或 Canvas 并自行绘制(动画)。这也不是太难,但您的需求将决定最好的做法是什么。因此,请先尝试帧动画,如果您发现它限制太多,请回发,我(或其他人)可以帮助您开始使用 SurfaceView。
Just to get you going you can try Frame Animation, it's part of the basic Animation package within Android, there is a relatively simple example on the official docs website here: http://developer.android.com/guide/topics/resources/animation-resource.html#Frame.
If you need more control of the animation you'll need to look in to using the SurfaceView or Canvas and do the drawing (animation) yourself. That's not too difficult either but your needs will dictate what the best thing to do is. So try the Frame Animation first, if you find it's too limiting post back and I (or some one else) can help you to get going with SurfaceView.