IjeomaMotion Event Listeners
in
Contributed Library Questions
•
2 years ago
I created some basic tweens with IjeomaMotion and inserted them into a tween sequence. The examples show a TweenSequenceEventListener class that tracks the start, end and repeat of a tween sequence. I was wondering if there was a way to track the start of individual tweens within the sequence. It seems like it should be pretty simple, but I'm a bit of a novice programmer. I used the examples to track the END of individual tweens within a tween sequence, but not the start of the individual tweens. Perhaps the answer is in keyframes or timelines? Pseudocode posted below. Thanks!
Tween tw1;
Tween tw2;
Tween tw3;
TweenSequence ts;
TweenSeqEvtListener tsel;
...
void setup(){
tw1 = new Tween("tw1", 0, 1, 4, 0f, Tween.LINEAR_BOTH);
tw2 = new Tween("tw2", 0, 1, 4, 0f, Tween.LINEAR_BOTH);
tw3 = new Tween("tw3", 0, 1, 4, 0f, Tween.LINEAR_BOTH);
...
ts.appendChild(tw1);
ts.appendChild(tw2);
ts.appendChild(tw3);
ts.addEventListener(tsel);
...
...
}
void draw() {
// Do some animation stuff
...
}
class TweenSequenceEventListener implements MotionEventListener {
public void onMotionEvent(MotionEvent te) {
if (te.type == MotionEvent.TWEEN_SEQUENCE_STARTED) {
println("Tween Sequence '" + ((TweenSequence) te.getSource()).getName() + "' started");
} else if (te.type == MotionEvent.TWEEN_SEQUENCE_ENDED) {
println("Tween Sequence '" + ((TweenSequence) te.getSource()).getName() + "' ended");
} else if (te.type == MotionEvent.TWEEN_SEQUENCE_REPEATED) {
println("Tween Sequence '" + ((TweenSequence) te.getSource()).getName() + "' repeated");
}
}
}
// This notifies the user of tween sequence events but not individual tween events
1