Answer the question
In order to leave comments, you need to log in
How to make in java follow method calls (ala sequence in tween engine)?
I want to make my own "bicycle" to control the animation. I wondered how to make a sequence of calls in Java simpler and more elegant.
Or, to be honest, how do you go about implementing such a construct?
Something like this:
AdvanceSprite.createSequence()
.set(x,y)
.move(x1,y1)
.pause(1000)
.set(x2,y2)
.hide()
.start()
Answer the question
In order to leave comments, you need to log in
Very simple, you just need to return the object itself that does the operations:
public static Sequence createSequence() {
return new Sequence();
}
public static class Sequence {
public Sequence set(int x, int y) {
// do something with x, y
return this;
}
public Sequence move(int x, int y) {
// do something with x, y
return this;
}
//...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question