1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#ifndef PUPPET_H
#define PUPPET_H
#include "ofMain.h"
#include "ofxSprite.h"
#include "ofxXmlSettings.h"
/*
"base" clip will be drawn unless another clip is playing
hoe to create synced anim at time
1) dead reckoning from outside
2) special clip@time method
3) change to timed clips (option?)
*/
class puppetSprite: public ofxSprite {
//puppetSprite loops by default
public:
void draw(float x, float y, float scale) {
getCurrentImage().draw(x-(anchorPoint.x*scale),y-(anchorPoint.y*scale),getWidth()*scale,getHeight()*scale);
}
int getDuration() {
return totalFrames*(1000/frameRate);
}
};
class Puppet
{
public:
Puppet();
virtual ~Puppet();
void load(string filename);
void play(string clip,int time=0);
void playNow(string clip,int time=0);
void draw(float x, float y, float scale=1.0f);
bool isPlaying();
void clear();
protected:
private:
map<string,puppetSprite> clips;
//deque<string> playlist;
deque< pair<int,string> > playlist; //time,clip = when it comes to play, pause until time, or just leave at 0 to play immediate
//time absolute
//need a clear method? should never be called really
};
#endif // PUPPET_H
|