- Main Page
- Classes
- Files

- File List

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

    00001 #ifndef _ANIMATION_H_
    00002 #define _ANIMATION_H_
    00003
    00004 #include <nds.h>
    00005 #include "woopsiarray.h"
    00006
    00007 namespace WoopsiUI {
    00008
    00012         class Animation {
    00013         public:
    00014
    00018                 enum Status {
    00019                         ANIMATION_STATUS_STOPPED = 0,
    00020                         ANIMATION_STATUS_PLAYING = 1,
    00021                         ANIMATION_STATUS_PAUSED = 2
    00022                 };
    00023
    00027                 enum LoopType {
    00028                         ANIMATION_LOOPTYPE_NONE = 0,
    00029                         ANIMATION_LOOPTYPE_LOOP = 1,
    00030                         ANIMATION_LOOPTYPE_PINGPONG = 2
    00031                 };
    00032
    00036                 typedef struct {
    00037                         const u16* bitmap;
    00038                         u16 width;
    00039                         u16 height;
    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 u16* 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
    00119                 void addFrame(const u16* bitmap, const u16 width, const u16 height, const u8 delay);
    00120
    00124                 void run();
    00125
    00129                 void play();
    00130
    00135                 void stop();
    00136
    00140                 inline void pause() { _status = ANIMATION_STATUS_PAUSED; }
    00141
    00146                 void goToFrame(u16 frame);
    00147
    00148         private:
    00149                 WoopsiArray<AnimFrame> _frames;
    00150                 u8 _speed;
    00151                 u16 _frameTimer;
    00152                 u16 _currentFrame;
    00153                 s8 _frameInc;
    00154                 u16 _requestedLoops;
    00155                 u16 _loopCount;
    00157                 LoopType _loopType;
    00158                 Status _status;
    00164                 bool loop();
    00165         };
    00166 }
    00167
    00168 #endif

All Classes Functions Variables Enumerations Enumerator