rag
graphic 2d engine
MovieClip.h
1 //
2 // DisplayMovieClip.h
3 //
4 //
5 // Created by Iván Sánchez on 11/30/11.
6 //
7 
8 #ifndef rag_DisplayMovieClip_h
9 #define rag_DisplayMovieClip_h
10 
11 #include "DisplayObject.h"
12 
13 namespace rag
14 {
16  class MovieClip: public DisplayObject
17  {
18 
19  public:
20 
22  struct Frame
23  {
24  int index;
25  int duration;
26  std::string label;
27  DisplayObject* bitmap;
28  };
29 
30  MovieClip(std::vector<Frame> frames);
31  virtual ~MovieClip();
32 
34  int getCurrentFrame ( );
35 
37  std::string getCurrentFrameLabel ( );
38 
40  int getTotalFrames ( );
41 
43 
46  void play ( );
47 
49  void stop ( );
50 
52  void gotoAndPlay ( int frame );
53 
55  void gotoAndPlay ( const std::string& frame, bool loop, bool forceFirstFrame = false);
56 
58  void gotoAndStop ( int frame );
59 
61  void gotoAndStop ( const std::string& frame );
62 
64  void nextFrame ( );
65 
67  void prevFrame ( );
68 
71 
73  virtual void logicUpdate() override;
74 
76  void setFPS(int fps);
77 
79  void replace(const std::string& name, const std::string& library, const std::string& replacement);
80 
82  bool isPlaying();
83 
85  std::vector<Frame>& getFrames();
86 
88  std::string fileName;
89 
90  private:
91 
92  void setFrame(int frame);
93  int nextFrameNum();
94 
95  std::vector<Frame> frames;
96  Frame* currentFrame;
97  int currentIndex;
98  float elapsedFrameTime;
99  bool playing;
100  int framesLoaded;
101 
102  std::string animLoop;
103  bool loop;
104  int fps;
105  };
106 } // rag
107 
108 #endif
std::string fileName
MovieClip filename.
Definition: MovieClip.h:88
void nextFrame()
Sends the playhead to the next frame and stops it.
Definition: MovieClip.cpp:162
void replace(const std::string &name, const std::string &library, const std::string &replacement)
Replace an instance of a Displayobject named "name" with a library item called "replacement".
Definition: MovieClip.cpp:204
Allows to use imported animations created by Flash CS tool.
Definition: MovieClip.h:16
void setFPS(int fps)
Sets the speed in frames per second the MovieClip should use.
Definition: MovieClip.cpp:70
void gotoAndStop(int frame)
Goes to a specific frame, then stops there.
Definition: MovieClip.cpp:115
Definition: Bitmap.h:8
void prevFrame()
Sends the playhead to the previous frame and stops it.
Definition: MovieClip.cpp:167
void stop()
Stops the playhead in the movie clip.
Definition: MovieClip.cpp:81
void play()
Simple playback.
Definition: MovieClip.cpp:75
Internal of MovieClip, represents a single frame.
Definition: MovieClip.h:22
virtual void logicUpdate() override
Display object update.
Definition: MovieClip.cpp:38
Core object used to display things in screen.
Definition: DisplayObject.h:23
bool isPlaying()
Returns true if is currently playing.
Definition: MovieClip.cpp:65
int getTotalFrames()
Returns the total number of frames in the MovieClip.
Definition: MovieClip.cpp:177
Frame * getCurrentFrameNode()
Returns the current frame internals.
Definition: MovieClip.cpp:182
std::string getCurrentFrameLabel()
Returns the label in the current frame. It may be empty.
Definition: MovieClip.cpp:197
int getCurrentFrame()
Specifies the number of the frame in which the playhead is located in the timeline of the MovieClip i...
Definition: MovieClip.cpp:187
void gotoAndPlay(int frame)
Goes to a specific frame, then starts playing from there.
Definition: MovieClip.cpp:86
MovieClip(std::vector< Frame > frames)
Definition: MovieClip.cpp:11
std::vector< Frame > & getFrames()
Returns all Frame instances.
Definition: MovieClip.cpp:228