Not sure if all this is needed

This commit is contained in:
Jorim Tielemans 2019-07-31 17:54:23 +02:00
parent 619916b025
commit 454c5f7db7
2 changed files with 19 additions and 8 deletions

View File

@ -107,12 +107,12 @@ public:
GBAVector getPosAsVector() { return GBAVector(getPos()); }
VECTOR getCenter() { return { x + w / 2, y + h / 2 }; }
VECTOR getVelocity() { return { dx, dy}; }
u32 getX() { return x; }
u32 getY() { return y; }
u32 getDx() { return dx; }
u32 getDy() { return dy; }
u32 getX() { return x; }
u32 getHeight() { return h; }
u32 getWidth() { return w; }
u32 getY() { return y; }
u32 getHeight() { return h; }
u32 getCurrentFrame() { return currentFrame; }
bool isAnimating() { return animating; };
bool isOffScreen();

View File

@ -13,12 +13,12 @@ private:
bool stayWithinBounds = false;
const void *imageData;
u32 x, y, dx, dy;
u32 numberOfFrames, animationDelay;
u32 beginFrame, numberOfFrames, animationDelay;
SpriteSize size;
void setProperties(T* sprite);
void reset() {
imageSize = x = y = dx = dy = numberOfFrames = animationDelay = 0;
imageSize = x = y = dx = dy = beginFrame = numberOfFrames = animationDelay = 0;
imageData = nullptr;
stayWithinBounds = false;
size = SIZE_16_16;
@ -51,9 +51,16 @@ public:
this->size = size;
return *this;
}
SpriteBuilder& withAnimated(int numberOfFrames, int delay) {
SpriteBuilder& withAnimated(int numberOfFrames, int animationDelay) {
this->beginFrame = 0;
this->numberOfFrames = numberOfFrames;
this->animationDelay = delay;
this->animationDelay = animationDelay;
return *this;
}
SpriteBuilder& withAnimated(int beginFrame, int numberOfFrames, int animationDelay) {
this->beginFrame = beginFrame;
this->numberOfFrames = numberOfFrames;
this->animationDelay = animationDelay;
return *this;
}
T build();
@ -73,7 +80,11 @@ template<typename T> std::unique_ptr<T> SpriteBuilder<T>::buildWithDataOf(const
template<typename T> void SpriteBuilder<T>::setProperties(T* s) {
s->setVelocity(this->dx, this->dy);
if(this->numberOfFrames > 0) {
s->makeAnimated(this->numberOfFrames, this->animationDelay);
if(this->beginFrame > 0) {
s->makeAnimated(this->beginFrame, this->numberOfFrames, this->animationDelay);
} else {
s->makeAnimated(this->numberOfFrames, this->animationDelay);
}
}
s->setStayWithinBounds(stayWithinBounds);