- Main Page
- Classes
- Files

- File List

# C:/Documents and Settings/Administrator/Desktop/woopsi-src-0.40/Woopsi/libwoopsi/include/animation.h

    00001 #ifndef _ANIMATION_H_
    00002 #define _ANIMATION_H_
    00003
    00004 #include <nds.h>
    00005 #include "woopsiarray.h"
    00006
    00007 namespace WoopsiUI {
    00008
    00009         class BitmapBase;
    00010
    00014         class Animation {
    00015         public:
    00016
    00020                 enum Status {
    00021                         ANIMATION_STATUS_STOPPED = 0,
    00022                         ANIMATION_STATUS_PLAYING = 1,
    00023                         ANIMATION_STATUS_PAUSED = 2
    00024                 };
    00025
    00029                 enum LoopType {
    00030                         ANIMATION_LOOPTYPE_NONE = 0,
    00031                         ANIMATION_LOOPTYPE_LOOP = 1,
    00032                         ANIMATION_LOOPTYPE_PINGPONG = 2
    00033                 };
    00034
    00038                 typedef struct {
    00039                         const BitmapBase* bitmap;
    00040                         u8 delay;
    00041                 } AnimFrame;
    00042
    00049                 Animation(const u8 speed, const LoopType loopType, const u16 loops);
    00050
    00054                 inline ~Animation() { };
    00055
    00060                 inline const AnimFrame* getCurrentFrame() const { return &_frames[_currentFrame]; };
    00061
    00066                 inline const BitmapBase* getCurrentBitmap() const { return _frames[_currentFrame].bitmap; };
    00067
    00072                 inline const Status getStatus() const { return _status; };
    00073
    00078                 inline const u8 getSpeed() const { return _speed; };
    00079
    00084                 inline const LoopType getLoopType() const { return _loopType; };
    00085
    00091                 inline const u16 getTimeToNextFrame() const { return _frameTimer; };
    00092
    00097                 inline const u16 getFrameCount() const { return _frames.size(); };
    00098
    00103                 inline void setSpeed(const u8 speed) { _speed = speed; };
    00104
    00109                 inline void setLoopType(const LoopType loopType) { _loopType = loopType; };
    00110
    00117                 void addFrame(const BitmapBase* bitmap, const u8 delay);
    00118
    00122                 void run();
    00123
    00127                 void play();
    00128
    00133                 void stop();
    00134
    00138                 inline void pause() { _status = ANIMATION_STATUS_PAUSED; }
    00139
    00144                 void goToFrame(u16 frame);
    00145
    00146         private:
    00147                 WoopsiArray<AnimFrame> _frames;
    00148                 u8 _speed;
    00149                 u16 _frameTimer;
    00150                 u16 _currentFrame;
    00151                 s8 _frameInc;
    00152                 u16 _requestedLoops;
    00153                 u16 _loopCount;
    00155                 LoopType _loopType;
    00156                 Status _status;
    00162                 bool loop();
    00163         };
    00164 }
    00165
    00166 #endif