raju
raju

Reputation: 1264

how start frame animations in android?

I want to start 5 different frame animations:One for cap,one for scarf one for character,one fro face Expressions and one for scarf borders.I want it to look like man is running with scarf hat.Animations started fine, but all animations are not playing at same time. Please help me to do that.

I set the png images through addFrame method in my code .

I am posting the sample code here

   capanimation.setVisible(true,true);
    capanimation.start();
    Log.i("fani"," cap:  "+System.currentTimeMillis() );
    scarfmainanimaiton.setVisible(true,true);
    scarfmainanimaiton.start();
    Log.i("fani"," sca:  "+System.currentTimeMillis() );
    
    faceexpressionanimation.setVisible(true,true);
    faceexpressionanimation.start();
    Log.i("fani"," fac:  "+System.currentTimeMillis() );
    
    charecteranimation.setVisible(true,true);
    charecteranimation.start();
    Log.i("fani"," cha:  "+System.currentTimeMillis() );

Upvotes: 0

Views: 493

Answers (2)

raju
raju

Reputation: 1264

In may app i am giving choice to user to select cap,scarf among different options based on the user selection i need to animate that cahrecter with user selcted cap and scarf

     //Iam posting the some sample code here
     public  int maledance[]={R.drawable.char01,R.drawable.char02,R.drawable.char03,R.drawable.char04,R.drawable.char05,R.drawable.char06
                ,R.drawable.char07,R.drawable.char08,R.drawable.char09,R.drawable.char10,R.drawable.char11,R.drawable.char12,R.drawable.char13,R.drawable.char14,R.drawable.char15};

    public int maledancescarf1[]={R.drawable.scarve101,R.drawable.scarve102,R.drawable.scarve103,R.drawable.scarve104,R.drawable.scarve105,R.drawable.scarve106,
            R.drawable.scarve107,R.drawable.scarve108,R.drawable.scarve109,R.drawable.scarve110,R.drawable.scarve111,R.drawable.scarve112,R.drawable.scarve113,R.drawable.scarve114,R.drawable.scarve115};           

etc......

       charecteranimation=new AnimationDrawable();
        capanimation=new AnimationDrawable();
        capboarderanimation=new AnimationDrawable();
        scarfmainanimaiton=new AnimationDrawable();
        scarfboarderanimation=new AnimationDrawable();
        faceexpressionanimation=new AnimationDrawable();
        for(int i=0;i<maledance.length;i++)
        {
            Log.i("fani","string lenth is  "+maledance.length+" delay is "+delay);
        charecteranimation.addFrame(getResources().getDrawable(maledance[i]),t);
        capanimation.addFrame(getResources().getDrawable(maledancecap[i]),t);
        scarfmainanimaiton.addFrame(getResources().getDrawable(maledancescarf[i]),t);
        faceexpressionanimation.addFrame(getResources().getDrawable(malefaceexpression[i]),t);
        }
        capanimation.setOneShot(false);
        charecteranimation.setOneShot(false);
        scarfmainanimaiton.setOneShot(false);
        faceexpressionanimation.setOneShot(false);


        //in onwindowfocuschanged listner i am starting the animations

Upvotes: 0

The iCoder
The iCoder

Reputation: 1444

I think you can do this using frame by frame animation which is very easy. I will provide link for that check http://developer.android.com/guide/topics/graphics/drawable-animation.html In that you can put your images in resources folder and that can animated as per requirement. Hope this will help you.

Upvotes: 1

Related Questions