【发布时间】:2011-03-14 15:38:45
【问题描述】:
我应该使用什么算法或技术来使对象遵循用户在屏幕上绘制的路径?
【问题讨论】:
标签: android algorithm graphics path
我应该使用什么算法或技术来使对象遵循用户在屏幕上绘制的路径?
【问题讨论】:
标签: android algorithm graphics path
下面的例子创建了一个 PATH 用于在 Circle Path 上显示 TEXT:
// create a path
Path circle = new Path();
circle.addCircle(centerX, centerY, radius, Direction.CW);
// set the color and font size
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setTextSize(30);
paint.setAntiAlias(true);
// draw the text along the circle
canvas.drawTextOnPath(QUOTE, circle, 0, 30, paint);
可以参考全文 Example Here
而对于动画,Android SDK 提供的动画主要有 4 种类型:
有关创建动画序列,请参阅 Example Here。
对于不同类型的动画示例,例如帧动画(如在 Flash 中)、列表动画等。可以参考Animations Types EXample here 。
享受!!
【讨论】:
在过去的几周里,我只是在为一个游戏做这件事——我是如何做到的,是从触摸事件(当用户将其绘制到屏幕上时)给出的坐标中获取每个点,然后添加它到一个列表。我将该列表转换为绘制到屏幕的路径,然后让对象根据每一帧的 onDraw 方法中的列表更新其位置。
【讨论】: