Added background-alpha tweening.

This commit is contained in:
emb 2015-01-12 23:56:19 -06:00
parent f823d497a9
commit ac3552ff91
4 changed files with 9 additions and 1 deletions

View File

@ -55,6 +55,7 @@ bool Tween::GetTweenProperty(std::string name, TweenProperty &property)
TweenPropertyMap["xoffset"] = TWEEN_PROPERTY_X_OFFSET;
TweenPropertyMap["yoffset"] = TWEEN_PROPERTY_Y_OFFSET;
TweenPropertyMap["fontSize"] = TWEEN_PROPERTY_FONT_SIZE;
TweenPropertyMap["backgroundalpha"] = TWEEN_PROPERTY_BACKGROUND_ALPHA;
}
std::transform(name.begin(), name.end(), name.begin(), ::tolower);

View File

@ -41,5 +41,6 @@ enum TweenProperty
TWEEN_PROPERTY_Y_ORIGIN,
TWEEN_PROPERTY_X_OFFSET,
TWEEN_PROPERTY_Y_OFFSET,
TWEEN_PROPERTY_FONT_SIZE
TWEEN_PROPERTY_FONT_SIZE,
TWEEN_PROPERTY_BACKGROUND_ALPHA,
};

View File

@ -314,6 +314,10 @@ bool Component::Animate(bool loop)
case TWEEN_PROPERTY_FONT_SIZE:
GetBaseViewInfo()->SetFontSize(value);
break;
case TWEEN_PROPERTY_BACKGROUND_ALPHA:
GetBaseViewInfo()->SetBackgroundAlpha(value);
break;
}
}

View File

@ -334,6 +334,7 @@ void ScrollingList::Update(float dt)
currentViewInfo->SetImageWidth(c->GetBaseViewInfo()->GetImageWidth());
nextViewInfo->SetImageHeight(c->GetBaseViewInfo()->GetImageHeight());
nextViewInfo->SetImageWidth(c->GetBaseViewInfo()->GetImageWidth());
nextViewInfo->SetBackgroundAlpha(c->GetBaseViewInfo()->GetBackgroundAlpha());
//todo: 30 is a magic number
ViewInfo *spriteViewInfo = c->GetBaseViewInfo();
@ -349,6 +350,7 @@ void ScrollingList::Update(float dt)
spriteViewInfo->SetAlpha(Tween::AnimateSingle(LINEAR, currentViewInfo->GetAlpha(), nextViewInfo->GetAlpha(), scrollPeriod, CurrentAnimateTime));
spriteViewInfo->SetAngle(Tween::AnimateSingle(LINEAR, currentViewInfo->GetAngle(), nextViewInfo->GetAngle(), scrollPeriod, CurrentAnimateTime));
spriteViewInfo->SetFontSize(Tween::AnimateSingle(LINEAR, currentViewInfo->GetFontSize(), nextViewInfo->GetFontSize(), scrollPeriod, CurrentAnimateTime));
spriteViewInfo->SetBackgroundAlpha(Tween::AnimateSingle(LINEAR, currentViewInfo->GetBackgroundAlpha(), nextViewInfo->GetBackgroundAlpha(), scrollPeriod, CurrentAnimateTime));
c->Update(dt);
}