timeline - shaking Stage in javaFX -


is possible shake primary stage timeline , use xtimeline , ytimeline?

    final timeline xtimeline = new timeline();//for animate on x'-stage     xtimeline.setcyclecount(timeline.indefinite);     xtimeline.setautoreverse(true);     final timeline ytimeline = new timeline();//for animate on y'-stage     ytimeline.setcyclecount(timeline.indefinite);     ytimeline.setautoreverse(true); 

try this..

int x = 0; int y = 0;  public void shakestage() {         timeline timelinex = new timeline(new keyframe(duration.seconds(0.1), new eventhandler<actionevent>() {             @override             public void handle(actionevent t) {                 if (x == 0) {                     primarystage.setx(primarystage.getx() + 10);                     x = 1;                 } else {                     primarystage.setx(primarystage.getx() - 10);                     x = 0;                 }             }         }));          timelinex.setcyclecount(timeline.indefinite);         timelinex.setautoreverse(false);         timelinex.play();           timeline timeliney = new timeline(new keyframe(duration.seconds(0.1), new eventhandler<actionevent>() {             @override             public void handle(actionevent t) {                 if (y == 0) {                     primarystage.sety(primarystage.gety() + 10);                     y = 1;                 } else {                     primarystage.sety(primarystage.gety() - 10);                     y = 0;                 }             }         }));          timeliney.setcyclecount(timeline.indefinite);         timeliney.setautoreverse(false);         timeliney.play();     } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -