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); }
public void handleEvent(Event event) { if (event.isOfType(KeyPressedEvent.TYPE)) { handleKeyPressed((KeyPressedEvent) event); } else if (event.isOfType(MenuStateEvent.TYPE)) { this.selectedItem = ((MenuStateEvent) event).getSelectedItem(); door.setPosition(207 + 300 * this.selectedItem, 477); SoundHandle soundHandle = new SoundHandle("changeMenu_handle", "changeMenu.wav"); soundHandle.load(this.getCore()); SoundService.getInstance(this.getCore()).play((SoundEffect) soundHandle.getResource()); } }