java - Custom Animation end trigger -


i'm writing "space invaders" style app , needed move stop repeat animation classic game. got processes go 1 way, using code below, when want go back, there not seem easy way this. think easiest way have happen on end animation event, cannot event trigger, when calling super.end();. i've looked around way trigger event manually no avail. way doing may little sketchy works enough right try , make work way.

public void start() {     if(begin < end) //recursive end condition     {          int distance = interval + begin; //change distance traveled         //create new animation part of whole animation         objectanimator anim = objectanimator.offloat(toanimate, property, begin,distance);         timeinterpolator inter = new timeinterpolator() //makes animation move 1 frame         {             public float getinterpolation(float prog)             {                 return math.round(prog * 10) / 10;             }         };         anim.setinterpolator(inter);         anim.setduration((long)(500));         anim.addlistener(new animatorlistener()         {             @override             public void onanimationstart(animator animation){}             @override             public void onanimationend(animator animation)             {                 start(); //start next part of movement             }             @override             public void onanimationcancel(animator animation){}             @override             public void onanimationrepeat(animator animation){}         });         begin = begin + interval; //update end recursion value         anim.start(); //begin animation     }     super.end(); //this doesn't work... rip } 

public void start() {     if(begin < end) //recursive end condition     {          int distance = interval + begin; //change distance traveled         //create new animation part of whole animation         objectanimator anim = objectanimator.offloat(toanimate, property, begin,distance);         timeinterpolator inter = new timeinterpolator() //makes animation move 1 frame         {             public float getinterpolation(float prog)             {                 return math.round(prog * 10) / 10;             }         };         anim.setinterpolator(inter);         anim.setduration((long)(500));         anim.addlistener(new animatorlistener()         {             @override             public void onanimationstart(animator animation){}             @override             public void onanimationend(animator animation)             {                 begin += interval;                 if(begin < end){                    start(); //start next part of movement                 }                 else{                     // else                 }             }             @override             public void onanimationcancel(animator animation){}             @override             public void onanimationrepeat(animator animation){}         });         anim.start(); //begin animation     } } 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -