mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
Added support for playing and stopping animations.
svn-id: r42075
This commit is contained in:
parent
63d0fdea68
commit
a4e6464a63
@ -28,16 +28,31 @@
|
||||
|
||||
namespace Draci {
|
||||
|
||||
void Animation::addAnimation(uint id, uint z) {
|
||||
void Animation::addAnimation(uint id, uint z, bool playing) {
|
||||
|
||||
AnimObj *obj = new AnimObj();
|
||||
obj->_id = id;
|
||||
obj->_z = z;
|
||||
obj->_currentFrame = 0;
|
||||
obj->_playing = playing;
|
||||
|
||||
insertAnimation(*obj);
|
||||
}
|
||||
|
||||
void Animation::play(uint id) {
|
||||
|
||||
AnimObj &obj = *getAnimation(id);
|
||||
|
||||
obj._playing = true;
|
||||
}
|
||||
|
||||
void Animation::stop(uint id) {
|
||||
|
||||
AnimObj &obj = *getAnimation(id);
|
||||
|
||||
obj._playing = false;
|
||||
}
|
||||
|
||||
Common::List<AnimObj>::iterator Animation::getAnimation(uint id) {
|
||||
|
||||
Common::List<AnimObj>::iterator it;
|
||||
@ -75,6 +90,7 @@ void Animation::addOverlay(Drawable *overlay, uint z) {
|
||||
obj->_id = kOverlayImage;
|
||||
obj->_z = z;
|
||||
obj->_currentFrame = 0;
|
||||
obj->_playing = true;
|
||||
obj->_frames.push_back(overlay);
|
||||
|
||||
insertAnimation(*obj);
|
||||
@ -85,7 +101,11 @@ void Animation::drawScene(Surface *surf) {
|
||||
Common::List<AnimObj>::iterator it;
|
||||
|
||||
for (it = _animObjects.begin(); it != _animObjects.end(); ++it) {
|
||||
if(it->_id == kOverlayImage) {
|
||||
if (!it->_playing) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (it->_id == kOverlayImage) {
|
||||
it->_frames[it->_currentFrame]->draw(surf, false);
|
||||
}
|
||||
else {
|
||||
@ -98,7 +118,7 @@ void Animation::deleteAnimation(uint id) {
|
||||
|
||||
Common::List<AnimObj>::iterator it = getAnimation(id);
|
||||
|
||||
for(uint i = 0; i < it->_frames.size(); ++i) {
|
||||
for (uint i = 0; i < it->_frames.size(); ++i) {
|
||||
delete it->_frames[i];
|
||||
}
|
||||
|
||||
@ -110,7 +130,7 @@ void Animation::deleteAll() {
|
||||
Common::List<AnimObj>::iterator it;
|
||||
|
||||
for (it = _animObjects.begin(); it != _animObjects.end(); ++it) {
|
||||
for(uint i = 0; i < it->_frames.size(); ++i) {
|
||||
for (uint i = 0; i < it->_frames.size(); ++i) {
|
||||
delete it->_frames[i];
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ struct AnimObj {
|
||||
uint _id;
|
||||
uint _currentFrame;
|
||||
uint _z;
|
||||
bool _playing;
|
||||
Common::Array<Drawable*> _frames;
|
||||
};
|
||||
|
||||
@ -47,12 +48,18 @@ public:
|
||||
Animation(DraciEngine *vm) : _vm(vm) {};
|
||||
~Animation() { deleteAll(); }
|
||||
|
||||
void addAnimation(uint id, uint z = 0);
|
||||
void addAnimation(uint id, uint z, bool playing = false);
|
||||
void addFrame(uint id, Drawable *frame);
|
||||
void addOverlay(Drawable *overlay, uint z = 0);
|
||||
void addOverlay(Drawable *overlay, uint z);
|
||||
|
||||
void play(uint id);
|
||||
void stop(uint id);
|
||||
|
||||
void deleteAnimation(uint id);
|
||||
void deleteAll();
|
||||
|
||||
void drawScene(Surface *surf);
|
||||
|
||||
Common::List<AnimObj>::iterator getAnimation(uint id);
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user