Added volume animation.

This commit is contained in:
Pieter Hulshoff 2019-03-24 21:48:05 +01:00
parent 46cc7084d1
commit 1d54362885
5 changed files with 12 additions and 0 deletions

View File

@ -58,6 +58,7 @@ bool Tween::getTweenProperty(std::string name, TweenProperty &property)
tweenPropertyMap_["containery"] = TWEEN_PROPERTY_CONTAINER_Y;
tweenPropertyMap_["containerwidth"] = TWEEN_PROPERTY_CONTAINER_WIDTH;
tweenPropertyMap_["containerheight"] = TWEEN_PROPERTY_CONTAINER_HEIGHT;
tweenPropertyMap_["volume"] = TWEEN_PROPERTY_VOLUME;
tweenPropertyMap_["nop"] = TWEEN_PROPERTY_NOP;
}

View File

@ -62,5 +62,6 @@ enum TweenProperty
TWEEN_PROPERTY_CONTAINER_Y,
TWEEN_PROPERTY_CONTAINER_WIDTH,
TWEEN_PROPERTY_CONTAINER_HEIGHT,
TWEEN_PROPERTY_VOLUME,
TWEEN_PROPERTY_NOP,
};

View File

@ -175,6 +175,7 @@ void Component::update(float dt)
currentTweenIndex_ = 0;
elapsedTweenTime_ = 0;
storeViewInfo_ = baseViewInfo;
storeVolume_ = getVolume();
currentTweenComplete_ = false;
}
animationRequested_ = false;
@ -194,6 +195,7 @@ void Component::update(float dt)
currentTweenIndex_ = 0;
elapsedTweenTime_ = 0;
storeViewInfo_ = baseViewInfo;
storeVolume_ = getVolume();
currentTweenComplete_ = false;
animationRequested_ = false;
}
@ -385,6 +387,12 @@ bool Component::animate()
baseViewInfo.ContainerHeight = tween->animate(elapsedTime, storeViewInfo_.ContainerHeight);
break;
case TWEEN_PROPERTY_VOLUME:
if (tween->startDefined)
setVolume(tween->animate(elapsedTime));
else
setVolume(tween->animate(elapsedTime, storeVolume_));
case TWEEN_PROPERTY_NOP:
break;
}

View File

@ -72,6 +72,7 @@ private:
SDL_Texture *backgroundTexture_;
ViewInfo storeViewInfo_;
double storeVolume_;
unsigned int currentTweenIndex_;
bool currentTweenComplete_;
float elapsedTweenTime_;

View File

@ -1428,6 +1428,7 @@ void PageBuilder::getAnimationEvents(xml_node<> *node, TweenSet &tweens)
case TWEEN_PROPERTY_FONT_SIZE:
case TWEEN_PROPERTY_CONTAINER_Y:
case TWEEN_PROPERTY_CONTAINER_HEIGHT:
case TWEEN_PROPERTY_VOLUME:
fromValue = getVerticalAlignment(from, 0);
toValue = getVerticalAlignment(to, 0);
break;