如何绘制动画在画布上?(机器人) [英] How to draw animation on a canvas ?(android)

查看:111
本文介绍了如何绘制动画在画布上?(机器人)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,当用户触摸到screen.I知道基本展现在画布上的动画,以及如何绘制位图到画布上,但我无法找到图纸什么好东西,或显示在canvas.i动画将使用逐帧动画,它会出现在相同位置的用户感动,这就是为什么我不能使用ImageView的。

I am trying to show an animation on a canvas when user touches to the screen.I know basics and how to draw a bitmap on to canvas but i couldn't find anything good on drawing or showing animation on canvas.i will use frame by frame animation and it will appear at the same position user touched that is why i can't use ImageView.

推荐答案

不知道是否有这样做的内置方式。但它是相当简单,以简单地加载位图到一个数组。

Not sure if there is a built-in way of doing this. But it's fairly straightforward to simply load the bitmaps into an array.

然后调用无效(),您的OnDraw()方法应该无效()本身并在下次运行计算哪一帧显示(通过计算时间的最后一帧被显示)。每一次你玩一个框,你增加帧计数器和复位时间计数器。

Then call invalidate(), your onDraw() method should invalidate() itself and on the next run calculate which frame to display (by calculating the time the last frame was displayed). Every time you play a frame you increase the frame counter and reset the time counter.

您可以使用可变延迟,这是非常容易实现。

You can use a variable delay, and it's fairly easy to implement.

这篇关于如何绘制动画在画布上?(机器人)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆