1
我在使对象跟随用触摸事件绘制的路径时遇到了一些麻烦。 问题更多的是物体跟随路径的平滑度。如何让对象遵循路径
/* the ACTION_MOVE code */
Hashtable<String, Integer> ht = new Hashtable<String, Integer>();
for (int h = 0; h < historySize; h++) {
for (int p = 0; p < pointerCount; p++) {
int newX = (int) event.getHistoricalX(p, h);
int newY = (int) event.getHistoricalY(p, h);
ht.put("x", newX);
ht.put("y", newY);
droid.path.add(ht);
}
droid.p.lineTo(x, y);
}
/* There's a game loop that calls a move() method on this droid object. In move I read the path list
and see the next coordinate to move the object to. */
我抢的坐标为用户跨使用 历史性的方法,所以我不会错过任何点屏幕拖动手指。
问题是物体沿着这条路径移动的平滑度。
如果您绘制路径慢那么机器人就会慢慢地在屏幕上 (因为更多的X,Y点捕获?) 移动,但如果你画线快那么机器人动作真快。
我需要物体以一致的速度在整个路径上移动。
我不知何故需要调节或添加到哈希表中的点处点以所以其一致读取 采样率之间的间距和物体看起来平滑 路径以下。
我已经使用了这个好一点,我有一些麻烦找到任何东西。 任何推向正确的方向将不胜感激。
非常感谢!
我还没有在这个项目上工作过一段时间,但是非常感谢发帖。我只是想着再次发射它,所以我会给这个镜头。 – jacklin 2012-02-24 20:03:01