Effects now use Constructor and Destructor to initialize or delete their data, instead of using start() and stop().

This commit is contained in:
2019-06-18 18:09:05 +02:00
parent 72cdb46451
commit 1912772da3
13 changed files with 58 additions and 60 deletions

View File

@ -1,24 +1,21 @@
#include "effect_animation.h"
#include "functions.h"
AnimationEffect::AnimationEffect(AnimationData* anim, CRGB* bg, int x, int y) {
this->animation_data = anim;
AnimationEffect::AnimationEffect(const char* name, CRGB* bg, int x, int y) {
this->bg_color = bg;
this->xOffset = x;
this->yOffset = y;
}
void AnimationEffect::start() {
this->animation = new Animation(this->animation_data);
this->animation = new Animation(name, window);
this->animation->setBgColor(this->bg_color);
this->animation->setOffsets(this->xOffset, this->yOffset);
}
void AnimationEffect::stop() {
AnimationEffect::~AnimationEffect() {
delete this->animation;
}
void AnimationEffect::loop() {
this->animation->drawFrame(this->window);
this->animation->drawFrame();
this->animation->advance();
}