I am currently developing a game in which the computer makes a path along points in an arraylist according to the travelling salesman problem algorithm. With each iteration I need the previous path to reset. At the moment each new path generated by the iterations is drawing on top of the previous so it all looks really messy. The function path.reset() doesn't seem to work as it should according to the android docs. This is my code, could anyone point out where I'm going wrong??
//this class draws a line
public void CompDrawLine(List test) {
// int d = 0;
int i=0;
test.add(test.get(0));
Point c = test.get(i);
for (i=0;i<(test.size()-1);i++) {
cPath.moveTo(c.x,c.y);
c = test.get(i+1);
cPath.lineTo(c.x,c.y);
mCanvas.drawPath(cPath,cPaint);
cPath.reset();
}
// cPath.reset();
invalidate();
}