WallpaperService draw() 内部的平滑动画
Smooth animations inside of WallpaperService draw()
我目前正在 draw()
方法中递增浮点变量来改变 Bitmap
的 x
和 y
坐标,尽管结果非常不稳定并且你可以看到它增加时的跳跃。我应该创建一个线程来增加坐标吗??
我的绘制方法代码:
x += 2.5;
y += 2.5;
c.drawBitmap(image, x, y, p);
c.drawBitmap(image, x - image.getWidth(), y, null);
c.drawBitmap(image, x, y - image.getHeight(), null);
c.drawBitmap(image, x - image.getWidth(), y - image.getHeight(), null);
但似乎动画太慢或断断续续。如何更改我的代码,使动画在任何 "speed" 时都显得流畅??
提前致谢!
原来我用错了Canvas。正在设置:
Canvas c = null;
而不是
Canvas c = new Canvas();
我目前正在 draw()
方法中递增浮点变量来改变 Bitmap
的 x
和 y
坐标,尽管结果非常不稳定并且你可以看到它增加时的跳跃。我应该创建一个线程来增加坐标吗??
我的绘制方法代码:
x += 2.5;
y += 2.5;
c.drawBitmap(image, x, y, p);
c.drawBitmap(image, x - image.getWidth(), y, null);
c.drawBitmap(image, x, y - image.getHeight(), null);
c.drawBitmap(image, x - image.getWidth(), y - image.getHeight(), null);
但似乎动画太慢或断断续续。如何更改我的代码,使动画在任何 "speed" 时都显得流畅??
提前致谢!
原来我用错了Canvas。正在设置:
Canvas c = null;
而不是
Canvas c = new Canvas();