Animation in android (make a person run)

I'm relatively new to android animation and just feel a couple of things. I want to know how I can make a “man” (image) on an android. The man is an icon.IF, I use animations through the following code, the icon simply moves around the screen. How can I get the current movement.

       public anima1(Context context) 
{
    super(context);
    cloud=BitmapFactory.decodeResource(getResources(),R.drawable.androidicon);


    // TODO Auto-generated constructor stub
}



       protected  void onDraw(Canvas canvas)
{
    super.onDraw(canvas);

    Rect re=new Rect();
    re.set(0,0,canvas.getWidth(),canvas.getHeight());
    Paint c=new Paint();
    c.setColor(Color.WHITE);
    c.setStyle(Paint.Style.FILL);
    canvas.drawRect(re,c);

    x=x+10;
    if(x==canvas.getWidth())
    {
    y=y+10;
    x=0;
    }
    if(y==canvas.getHeight())
    {
        x=0;
        y=0;
    }
    canvas.drawBitmap(cloud, x, y,p);



     invalidate();



}
+3
source share
1 answer

To make a person appear to be running, you should have several different images of a person with his legs in different positions and change the image on each cycle. Alternatively, you can use an animated GIF, but I'm not sure if Android will actually play the animation.

0
source

All Articles