From 8d7b7ef567c83416dc658d0e75172afc47b25e70 Mon Sep 17 00:00:00 2001 From: yugecin Date: Tue, 26 Jun 2018 21:49:41 +0200 Subject: [PATCH] main menu logo tweaks Minor changes to the logo scale Pulsing effect: let the ghost logo expand also animate the initial shrink --- src/itdelatrisu/opsu/GameImage.java | 5 ++--- src/itdelatrisu/opsu/states/MainMenu.java | 18 ++++++++++++------ src/itdelatrisu/opsu/ui/MenuButton.java | 14 +++++++------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/itdelatrisu/opsu/GameImage.java b/src/itdelatrisu/opsu/GameImage.java index 06023610..2209ef57 100644 --- a/src/itdelatrisu/opsu/GameImage.java +++ b/src/itdelatrisu/opsu/GameImage.java @@ -18,7 +18,6 @@ package itdelatrisu.opsu; -import itdelatrisu.opsu.ui.Colors; import itdelatrisu.opsu.ui.Fonts; import java.io.File; @@ -300,13 +299,13 @@ public enum GameImage { MENU_LOGO ("logo2", "png", false, true) { @Override protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy(0.8f); + return img.getScaledCopy(0.75f); } }, MENU_LOGO_PIECE ("logo2piece2", "png", false, true) { @Override protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy(0.8f); + return img.getScaledCopy(0.75f); } }, MENU_PLAY ("menu-play2", "png", false, false) { diff --git a/src/itdelatrisu/opsu/states/MainMenu.java b/src/itdelatrisu/opsu/states/MainMenu.java index c1b98aad..80e791e7 100644 --- a/src/itdelatrisu/opsu/states/MainMenu.java +++ b/src/itdelatrisu/opsu/states/MainMenu.java @@ -145,11 +145,11 @@ public class MainMenu extends BaseOpsuState { logo.setHoverAnimationDuration(logoAnimationDuration); playButton.setHoverAnimationDuration(logoAnimationDuration); exitButton.setHoverAnimationDuration(logoAnimationDuration); - final AnimationEquation logoAnimationEquation = AnimationEquation.IN_OUT_BACK; + final AnimationEquation logoAnimationEquation = AnimationEquation.IN_OUT_EXPO; logo.setHoverAnimationEquation(logoAnimationEquation); playButton.setHoverAnimationEquation(logoAnimationEquation); exitButton.setHoverAnimationEquation(logoAnimationEquation); - final float logoHoverScale = 1.08f; + final float logoHoverScale = 1.096f; logo.setHoverExpand(logoHoverScale); playButton.setHoverExpand(logoHoverScale); exitButton.setHoverExpand(logoHoverScale); @@ -265,15 +265,21 @@ public class MainMenu extends BaseOpsuState { boolean renderPiece = position != null; if (position == null) { position = System.currentTimeMillis() % 1000 / 1000f; + if (position < 0.05f) { + position = 1f - AnimationEquation.IN_CUBIC.calc(position / 0.05f); + } else { + position = (position - 0.05f) / 0.95f; + } } - float scale = 1f + position * 0.05f; - logo.draw(color, scale); + logo.draw(color, 0.9726f + position * 0.0274f); + final float hoverScale = logo.getCurrentHoverExpandValue(); if (renderPiece) { - Image piece = GameImage.MENU_LOGO_PIECE.getImage().getScaledCopy(logo.getLastScale()); + Image piece = GameImage.MENU_LOGO_PIECE.getImage(); + piece = piece.getScaledCopy(hoverScale); piece.rotate(position * 360); piece.drawCentered(logo.getX(), logo.getY(), color); } - float ghostScale = logo.getLastScale() / scale * 1.05f; + final float ghostScale = hoverScale * 1.0186f - position * 0.0186f; Image ghostLogo = GameImage.MENU_LOGO.getImage().getScaledCopy(ghostScale); ghostLogo.setAlpha(0.25f); ghostLogo.drawCentered(logo.getX(), logo.getY(), color); diff --git a/src/itdelatrisu/opsu/ui/MenuButton.java b/src/itdelatrisu/opsu/ui/MenuButton.java index a155d270..d27e1b7c 100644 --- a/src/itdelatrisu/opsu/ui/MenuButton.java +++ b/src/itdelatrisu/opsu/ui/MenuButton.java @@ -98,9 +98,6 @@ public class MenuButton { /** The default max rotation angle of the button. */ private static final float DEFAULT_ANGLE_MAX = 30f; - /** The last scale at which the button was drawn. */ - private float lastScale = 1f; - /** * Creates a new button from an Image. * @param img the image @@ -170,9 +167,14 @@ public class MenuButton { public float getY() { return y; } /** - * Returns the last scale at which the button was drawn. + * Returns the scale multiplier, from the hover effect, used to draw the button. */ - public float getLastScale() { return lastScale; } + public float getCurrentHoverExpandValue() { + if ((hoverEffect & EFFECT_EXPAND) == 0) { + return 1f; + } + return scale.getValue(); + } /** * Sets text to draw in the middle of the button. @@ -229,7 +231,6 @@ public class MenuButton { xScaleOffset = image.getWidth() / 2f - xRadius; yScaleOffset = image.getHeight() / 2f - yRadius; } - lastScale = scaleOverride; if (hoverEffect == 0) image.draw(x - xRadius, y - yRadius, filter); else { @@ -243,7 +244,6 @@ public class MenuButton { xScaleOffset = image.getWidth() / 2f - xRadius; yScaleOffset = image.getHeight() / 2f - yRadius; } - lastScale *= scale.getValue(); } } if ((hoverEffect & EFFECT_FADE) > 0)