Back and Skip animation
removed minimum time before skip button is shown.
This commit is contained in:
parent
987a406123
commit
ffed4b260a
|
@ -22,6 +22,7 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.newdawn.slick.Animation;
|
||||
import org.newdawn.slick.Image;
|
||||
import org.newdawn.slick.SlickException;
|
||||
|
||||
|
@ -40,7 +41,7 @@ public enum GameImage {
|
|||
SECTION_PASS ("section-pass", "png"),
|
||||
SECTION_FAIL ("section-fail", "png"),
|
||||
WARNINGARROW ("play-warningarrow", "png"),
|
||||
SKIP ("play-skip", "png"),
|
||||
SKIP ("play-skip", "play-skip-%d","png"),
|
||||
COUNTDOWN_READY ("ready", "png") {
|
||||
@Override
|
||||
protected Image process_sub(Image img, int w, int h) {
|
||||
|
@ -138,7 +139,7 @@ public enum GameImage {
|
|||
COMBO_BURST ("comboburst", "comboburst-%d", "png"),
|
||||
SCOREBAR_BG ("scorebar-bg", "png"),
|
||||
SCOREBAR_COLOUR ("scorebar-colour", "scorebar-colour-%d", "png"),
|
||||
//scorebar-marker?
|
||||
//TODO scorebar-marker?
|
||||
SCOREBAR_KI ("scorebar-ki", "png"),
|
||||
SCOREBAR_KI_DANGER ("scorebar-kidanger", "png"),
|
||||
SCOREBAR_KI_DANGER2 ("scorebar-kidanger2", "png"),
|
||||
|
@ -268,8 +269,7 @@ public enum GameImage {
|
|||
return img.getScaledCopy((h * 0.3f) / img.getHeight());
|
||||
}
|
||||
},
|
||||
MENU_BACK ("menu-back", "png", false, false),
|
||||
//MENU_BACK ("menu-back", "menu-back-%d","png") //TODO menu-back animation
|
||||
MENU_BACK ("menu-back", "menu-back-%d","png"),
|
||||
MENU_BUTTON_BG ("menu-button-background", "png", false, false),
|
||||
MENU_TAB ("selection-tab", "png", false, false) {
|
||||
@Override
|
||||
|
@ -537,6 +537,17 @@ public enum GameImage {
|
|||
setDefaultImage();
|
||||
return (skinImage != null) ? skinImage : defaultImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Animation based on the image array.
|
||||
* If no image array exist, returns the single image as an animation.
|
||||
*/
|
||||
public Animation getAnimation(int duration){
|
||||
Image[] images = getImages();
|
||||
if (images == null)
|
||||
images = new Image[]{ getImage() };
|
||||
return new Animation(images, duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image array associated with this resource.
|
||||
|
|
|
@ -347,20 +347,23 @@ public class MenuButton {
|
|||
*/
|
||||
private void setHoverRadius() {
|
||||
int xOffset = 0, yOffset = 0;
|
||||
if (dir != Expand.CENTER) {
|
||||
// offset by difference between normal/scaled image dimensions
|
||||
xOffset = (int) ((scale - 1f) * img.getWidth());
|
||||
yOffset = (int) ((scale - 1f) * img.getHeight());
|
||||
if (dir == Expand.UP || dir == Expand.DOWN)
|
||||
xOffset = 0; // no horizontal offset
|
||||
if (dir == Expand.RIGHT || dir == Expand.LEFT)
|
||||
yOffset = 0; // no vertical offset
|
||||
if (dir == Expand.RIGHT || dir == Expand.DOWN_RIGHT || dir == Expand.UP_RIGHT)
|
||||
xOffset *= -1; // flip x for right
|
||||
if (dir == Expand.DOWN || dir == Expand.DOWN_LEFT || dir == Expand.DOWN_RIGHT)
|
||||
yOffset *= -1; // flip y for down
|
||||
if(img != null){
|
||||
if (dir != Expand.CENTER) {
|
||||
// offset by difference between normal/scaled image dimensions
|
||||
xOffset = (int) ((scale - 1f) * img.getWidth());
|
||||
yOffset = (int) ((scale - 1f) * img.getHeight());
|
||||
if (dir == Expand.UP || dir == Expand.DOWN)
|
||||
xOffset = 0; // no horizontal offset
|
||||
if (dir == Expand.RIGHT || dir == Expand.LEFT)
|
||||
yOffset = 0; // no vertical offset
|
||||
if (dir == Expand.RIGHT || dir == Expand.DOWN_RIGHT || dir == Expand.UP_RIGHT)
|
||||
xOffset *= -1; // flip x for right
|
||||
if (dir == Expand.DOWN || dir == Expand.DOWN_LEFT || dir == Expand.DOWN_RIGHT)
|
||||
yOffset *= -1; // flip y for down
|
||||
}
|
||||
this.xRadius = ((img.getWidth() * scale) + xOffset) / 2f;
|
||||
this.yRadius = ((img.getHeight() * scale) + yOffset) / 2f;
|
||||
|
||||
}
|
||||
this.xRadius = ((img.getWidth() * scale) + xOffset) / 2f;
|
||||
this.yRadius = ((img.getHeight() * scale) + yOffset) / 2f;
|
||||
}
|
||||
}
|
|
@ -229,11 +229,21 @@ public class Utils {
|
|||
DownloadNode.init(width, height);
|
||||
|
||||
// back button
|
||||
Image back = GameImage.MENU_BACK.getImage();
|
||||
backButton = new MenuButton(back,
|
||||
back.getWidth() / 2f,
|
||||
height - (back.getHeight() / 2f));
|
||||
//TODO: this is annoying perhaps we can just pass in GameImage to MenuButton?
|
||||
if (GameImage.MENU_BACK.getImages() != null){
|
||||
Animation back = GameImage.MENU_BACK.getAnimation(200);
|
||||
backButton = new MenuButton(back,
|
||||
back.getWidth() / 2f,
|
||||
height - (back.getHeight() / 2f));
|
||||
}else{
|
||||
Image back = GameImage.MENU_BACK.getImage();
|
||||
backButton = new MenuButton(GameImage.MENU_BACK.getImage(),
|
||||
back.getWidth() / 2f,
|
||||
height - (back.getHeight() / 2f));
|
||||
}
|
||||
backButton.setHoverExpand(MenuButton.Expand.UP_RIGHT);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,6 +45,7 @@ import java.util.Stack;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.newdawn.slick.Animation;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
|
@ -268,7 +269,6 @@ public class Game extends BasicGameState {
|
|||
|
||||
// skip beginning
|
||||
if (objectIndex == 0 &&
|
||||
firstObjectTime - SKIP_OFFSET > 5000 &&
|
||||
trackPosition < osu.objects[0].getTime() - SKIP_OFFSET)
|
||||
skipButton.draw();
|
||||
|
||||
|
@ -782,7 +782,6 @@ public class Game extends BasicGameState {
|
|||
int firstObjectTime = osu.objects[0].getTime();
|
||||
int trackPosition = MusicController.getPosition();
|
||||
if (objectIndex == 0 &&
|
||||
firstObjectTime - SKIP_OFFSET > 4000 &&
|
||||
trackPosition < firstObjectTime - SKIP_OFFSET) {
|
||||
if (isLeadIn()) {
|
||||
leadInTime = 0;
|
||||
|
@ -810,12 +809,20 @@ public class Game extends BasicGameState {
|
|||
}
|
||||
|
||||
// skip button
|
||||
Image skip = GameImage.SKIP.getImage();
|
||||
skipButton = new MenuButton(skip,
|
||||
width - (skip.getWidth() / 2f),
|
||||
height - (skip.getHeight() / 2f));
|
||||
//TODO: this is annoying perhaps we can just pass in GameImage to MenuButton?
|
||||
if (GameImage.SKIP.getImages() != null){
|
||||
Animation back = GameImage.SKIP.getAnimation(200);
|
||||
skipButton = new MenuButton(back,
|
||||
width - back.getWidth() / 2f,
|
||||
height - (back.getHeight() / 2f));
|
||||
}else{
|
||||
Image back = GameImage.SKIP.getImage();
|
||||
skipButton = new MenuButton(GameImage.SKIP.getImage(),
|
||||
width - back.getWidth() / 2f,
|
||||
height - (back.getHeight() / 2f));
|
||||
}
|
||||
skipButton.setHoverExpand(MenuButton.Expand.UP_LEFT);
|
||||
|
||||
|
||||
// load other images...
|
||||
((GamePauseMenu) game.getState(Opsu.STATE_GAMEPAUSEMENU)).loadImages();
|
||||
data.loadImages();
|
||||
|
|
Loading…
Reference in New Issue
Block a user