tags:

views:

271

answers:

2

Hi All,

I want to move the ball image on the desired path lets say a road with a "V" turn with the help of Accelerometer values.I have taken separate image for track with alpha non zero on track. Using alpha values i am calculating next point for the ball. This works fine for the part of the track parallel to X or Y axis.

But i am facing issues when moving the ball on slanted edges as shown below. Ball sometimes stuck up or gives jerks or moves out of the track.

------------------------------------------
 O                                       /
-------------------------------------   /
                                    /  /
                                   /  /
                                  /  /
                                 /  /
                                /  /

or (if image is not visible) please consider number seven image as track "7". Want to move the ball on track similar to like "7"

Help is needed in urgent.

Thanks in advance. Regards, Vishal Mali

+1  A: 

If you use an image, you should keep in mind that the resolution of those is finite. A slanted edge is not a straight line when magnified.

See this illustration:

          |
          |
        __|
       |
       |
      o|
     __|
    |
    |

If the 'o' is your ball, and it's moving down on the screen, it will get stuck on the pixel boundary. A better approach would be to vectorize or make a polygon of your ball path and calculate if the ball is still inside this polygon.

Emiel
A: 

Hi All,

I used ChipMunck for this and my problem is solved. Thanks for your answers.

Regards, Vishal.

Vishal Mali