draw a trail of a ball which i move on ontouch in android
<p>i am new to android and trying to build a maze game. i am able to draw the ball and maze but i also want a trail of ball to be draw as the player moves the ball...</p>

<p>i am getting touch coordinates by event.getx() and event.gety()
till now i am storing startX,startY and current ball coordinates in an array for drawLines method
but it is not working......</p>

<p>plz help....what to do </p>

<pre><code>protected void onDraw(Canvas canvas) 
{
 //maze generator code

//draw ball code



int sx= maze.getTouchXcoordinate();

    int sy=maze.getTouchYcoordiante();
pts.add((float)sx);
    pts.add((float)sy);
    pts.add((float)nowX);
    pts.add((float)(now);
    float[]cords=new float[pts.size()];
    for(int i=0;i&lt;pts.size();i++)
    {
        float f= pts.get(i);

        cords[i]=f;
    }

    canvas.drawLines(cords, line);
}
</code></pre>

<p>and my touchlistner</p>

<pre><code>public boolean onTouchEvent(MotionEvent event) {
    float x= event.getX();
    float y= event.getY();
    int nowX= maze.getnowX();
    int nowY= maze.getnowY();
    switch (event.getAction() &amp; MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        //check if ball is touched
        if(x == currentX &amp;&amp; y == currentY) 
{

            maze.setTouchCordinates(x,y);
                           touched =true;
}

    case MotionEvent.ACTION_UP:

        touched= false;
        return true;

case MotionEvent.ACTION_MOVE:
        if(touched) {
 invalidate();
    }
</code></pre>
