get the scale from the menubutton to scale the piece

This commit is contained in:
yugecin 2016-11-13 02:01:21 +01:00
parent d3684b922d
commit 2b585e376f
2 changed files with 13 additions and 1 deletions

View File

@ -309,7 +309,7 @@ public class MainMenu extends BasicGameState {
Image piece = GameImage.MENU_LOGO_PIECE.getImage();
float xRadius = piece.getWidth() / 2;
float yRadius = piece.getHeight() / 2;
piece = piece.getScaledCopy(scale);
piece = piece.getScaledCopy(logo.getCurrentScale());
float scaleposmodx = piece.getWidth() / 2 - xRadius;
float scaleposmody = piece.getHeight() / 2 - yRadius;
piece.rotate((float)(position * 360));

View File

@ -98,6 +98,12 @@ public class MenuButton {
/** The default max rotation angle of the button. */
private static final float DEFAULT_ANGLE_MAX = 30f;
private float currentScale = 1f;
public float getCurrentScale() {
return currentScale;
}
/**
* Creates a new button from an Image.
* @param img the image
@ -213,6 +219,8 @@ public class MenuButton {
image = anim.getCurrentFrame();
}
currentScale = 1f;
// normal images
if (imgL == null) {
float scaleposmodx = 0;
@ -221,6 +229,7 @@ public class MenuButton {
image = image.getScaledCopy(scaleoverride);
scaleposmodx = image.getWidth() / 2 - xRadius;
scaleposmody = image.getHeight() / 2 - yRadius;
currentScale = scaleoverride;
}
if (hoverEffect == 0)
image.draw(x - xRadius - scaleposmodx, y - yRadius - scaleposmody, filter);
@ -231,6 +240,9 @@ public class MenuButton {
if (scale.getValue() != 1f) {
image = image.getScaledCopy(scale.getValue());
image.setAlpha(oldAlpha);
scaleposmodx = image.getWidth() / 2 - xRadius;
scaleposmody = image.getHeight() / 2 - yRadius;
currentScale *= scale.getValue();
}
}
if ((hoverEffect & EFFECT_FADE) > 0)