/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Ocarina2D.Objects.Pause;
import java.awt.Graphics2D;
import Ocarina2D.GlobalVariables;
import Ocarina2D.ZeldaKeys;
import puppyeyes.engine.Actor;
import puppyeyes.engine.Settings.Input;
/**
*
* @author majora
*/
public class PauseMenu extends Actor {
// Screens: 0 = item 1 = equipment 2 = map 3 = status 4 = save
private int currentScreen = 0;
private int xpos = 0;
private int ypos = 180;
private boolean closing = false;
private ItemsMenu itemBG = new ItemsMenu();
private EquipmentMenu equipBG = new EquipmentMenu();
private MapMenu mapBG = new MapMenu();
private StatusMenu statusBG = new StatusMenu();
//private Sprite saveBG = new Sprite("Resources/Sprites/Pause Menu/itemscreen.png");
public PauseMenu() {
draw.setLayer(GlobalVariables.hudLayer);
currentScreen = 0;
xpos = 0;
ypos = 220;
itemBG.position.x = 25;
equipBG.position.x = -235;
statusBG.position.x = 285;
mapBG.position.x=545;
itemBG.targetX = 25;
equipBG.targetX = -235;
statusBG.targetX = 285;
mapBG.targetX=545;
// Sleep so that things are not stupidly fast.
try{ Thread.sleep(300); }
catch( InterruptedException e ) { }
}
@Override
public void step() {
// Open / close animation.
if (closing == false) { if (ypos >20) { ypos -=40; } }
else {
if (ypos <200) { ypos +=20; }
else { this.destroy(); }
}
// Detect keys
boolean pressEnter = Input.keyDown(ZeldaKeys.start);
boolean pressR = Input.keyDown(ZeldaKeys.r);
boolean pressL = Input.keyDown(ZeldaKeys.l);
boolean pressA = Input.keyDown(ZeldaKeys.a);
boolean pressB = Input.keyDown(ZeldaKeys.b);
Actor currentObject = null;
if (currentScreen==0) { currentObject = itemBG; }
itemBG.step();
equipBG.step();
statusBG.step();
mapBG.step();
if (pressEnter==true) { closing = true; }
if (pressR==true) { itemBG.slideLeft(); equipBG.slideLeft(); statusBG.slideLeft(); mapBG.slideLeft(); }
if (pressL==true) { itemBG.slideRight(); equipBG.slideRight(); statusBG.slideRight(); mapBG.slideRight(); }
}
@Override
public void draw(Graphics2D graphics, int x, int y) {
itemBG.draw(graphics, 0, ypos);
if (ypos==20) {
equipBG.draw(graphics, 0, 20);
statusBG.draw(graphics, 0, 20);
mapBG.draw(graphics, 0, 20);
}
}
@Override
public void destroy() {
// Sleep so that things are not stupidly fast.
try{ Thread.sleep(300); }
catch( InterruptedException e ) { }
// Destroy all menus
itemBG.destroy();
equipBG.destroy();
statusBG.destroy();
mapBG.destroy();
GlobalVariables.paused = false;
PauseDetect pauseDetect = new PauseDetect();
this.getLevel().addActor(pauseDetect);
super.destroy();
}
}