diff --git a/src/ofxAnimationPrimitives/Pattern.h b/src/ofxAnimationPrimitives/Pattern.h index 38f7671..11f2b2f 100644 --- a/src/ofxAnimationPrimitives/Pattern.h +++ b/src/ofxAnimationPrimitives/Pattern.h @@ -40,7 +40,7 @@ class ListPattern : public Pattern bool valid() const { return num > 0 || num == -1; } -//protected: +protected: int num; void tick() { if (num > 0) num--; } diff --git a/src/ofxAnimationPrimitives/Timer.h b/src/ofxAnimationPrimitives/Timer.h index ec757a8..11683ff 100644 --- a/src/ofxAnimationPrimitives/Timer.h +++ b/src/ofxAnimationPrimitives/Timer.h @@ -19,16 +19,18 @@ class Timer : protected Ticker { public: - ofEvent timerEvent; + ofEvent timerEvent; - Timer() : remain(0), duration(0), repeat(false) {} + Timer() : remain(0), duration(0), repeat(0) {} - void start(float duration, bool repeat = true) + void start(float duration, int repeat = -1) { this->duration = duration; this->remain = duration; this->repeat = repeat; + count = 0; + Ticker::play(); } @@ -37,10 +39,12 @@ class Timer : protected Ticker Ticker::stop(); } + int getCount() const { return count; } + protected: float remain, duration; - bool repeat; + int repeat, count; void tick(float delta) { @@ -48,10 +52,13 @@ class Timer : protected Ticker if (remain > 0) return; - static ofEventArgs args; - ofNotifyEvent(timerEvent, args, this); + int N = count; + ofNotifyEvent(timerEvent, N, this); + + count++; - if (repeat) + if (repeat < 0 + || count < repeat) { remain += duration; }