What algorithm or technique should I use to make an object follow the path that the user's drawing on the screen?
The below example creates a PATH for displying TEXT on Circle Path:
// create a path Path circle = new Path(); circle.addCircle(centerX, centerY, radius, Direction.CW);
// set the color and font size
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setTextSize(30);
paint.setAntiAlias(true);
// draw the text along the circle
canvas.drawTextOnPath(QUOTE, circle, 0, 30, paint);
You can refer full Example Here
And For Animation, There are mainly 4 Types of Animations comes up with Android SDK:
- AlphaAnimation – transparency changes
- RotateAnimation – rotations
- ScaleAnimation – growing or shrinking
- TranslateAnimation – position changes
For CREATING ANIMATION SEQUENCES, refer Example Here.
For Different Types of Animations Example such as Frame Animation (As in Flash), List Animation,etc. You can refer Animations Types EXample here .
Enjoy!!
I was just working on this in the last couple weeks for a game--how I did it was by getting each point from coordinates given by the touch event (when the user is drawing it to the screen) and then adding that to a list. I turned that list into a path to draw to the screen, and then just had the object update its location based on the list in the onDraw method for each frame.