Path

A Path is an easy way to have an image move smoothly from one location to another.

Here are some examples of using various types of Path in a BoardView class. In each case, thisTile is a Sprite of some type, such as an ImageSprite.

1. Moving in a straight line, taking 2000 milliseconds.

LinePath lpath = new LinePath(fromX, fromY, toX, toY, 2000L); thisTile.move(lpath);

2. A two-step path sequence.

LinePath lpath = new LinePath(fromX, fromY, toX, toY, 3000L); LinePath lpath2 = new LinePath(toX, toY, lastX, lastY, 2000L); PathSequence spath = new PathSequence(lpath, lpath2); thisTile.move(spath);

3. A path made of many line segments.

List points=new LinkedList; points.add(new Point(fromX, fromY)); points.add(new Point(nextX, nextY)); points.add(new Point(thirdX, thirdY)); points.add(new Point(lastX, lastY)); LineSegmentPath path =new LineSegmentPath(points); thisTile.move(path);