From 6ad962fc8b7ec6e7390be778012d17988cb81777 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 9 Mar 2018 14:34:05 +0900 Subject: [PATCH] Interpolate ParallaxContainer's scale Things were a bit jumpy when a screen was adjusting `ParallaxAmount`. This smoothes the applied scale changes to look great again. Most noticeable when hitting the retry hotkey (`~`) from gameplay. --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index febe52d775..97d6225534 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -66,8 +66,10 @@ protected override void Update() { Vector2 offset = (input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2) * ParallaxAmount; - content.Position = Interpolation.ValueAt(MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000), content.Position, offset, 0, 1000, Easing.OutQuint); - content.Scale = new Vector2(1 + ParallaxAmount); + double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000); + + content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, 1000, Easing.OutQuint); + content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + ParallaxAmount), 0, 1000, Easing.OutQuint); } firstUpdate = false;