public void engage() { EventManager.getInstance(this.getCore()).addListener(this, KeyPressedEvent.TYPE); EventManager.getInstance(this.getCore()).addListener(this, MenuStateEvent.TYPE); SceneManager scnMngr = SceneManager.getInstance(this.getCore()); scnMngr.setClearBackground(true); Overlay bg = scnMngr.createOverlay("background"); SpriteVisual bgSpr = scnMngr.createSpriteVisual("menu_background_spr"); bg.addVisual(bgSpr); bg.setPosition(512, 384); door = scnMngr.createOverlay("door"); SpriteVisual doorSpr = scnMngr.createSpriteVisual("menu_door_spr"); door.addVisual(doorSpr); door.setPosition(207 + 300 * this.selectedItem, 477); }
private void handleKeyPressed(KeyPressedEvent event) { switch (event.getKeyCode()) { case KeyEvent.VK_SPACE: case KeyEvent.VK_ENTER: EventManager.getInstance(this.getCore()).enqueueEvent(new SelectItemEvent(selectedItem)); break; case KeyEvent.VK_LEFT: case KeyEvent.VK_UP: EventManager.getInstance(this.getCore()) .enqueueEvent(new ChangeItemEvent(ChangeDirection.UP)); break; case KeyEvent.VK_RIGHT: case KeyEvent.VK_DOWN: EventManager.getInstance(this.getCore()) .enqueueEvent(new ChangeItemEvent(ChangeDirection.DOWN)); break; } }
public void disengage() { SceneManager scnMngr = SceneManager.getInstance(this.getCore()); scnMngr.destroyAll(); EventManager.getInstance(this.getCore()).removeListener(this); }