Menu(TwoD game) { this.game = game; batch = new SpriteBatch(); font = new BitmapFont(); font.setColor(Color.WHITE); camera = new OrthographicCamera(); viewport = new FitViewport(1024, 786, camera); viewport.apply(); stage = new Stage(viewport, batch); stage.setDebugAll(true); gearScreen = new GearScreen(); gearScreen.setBounds(512, 0, 512, 786); inventoryScreen = new InventoryScreen(); inventoryScreen.setBounds(0, 0, 512, 786); stage.addActor(gearScreen); stage.addActor(inventoryScreen); dnd = new DragAndDrop(); inputMultiplexer = new InputMultiplexer(); inputMultiplexer.addProcessor(this); inputMultiplexer.addProcessor(stage); }
@Override public void render(float delta) { viewport.apply(); Constants.setBG(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); final GlyphLayout easyLayout = new GlyphLayout(font, Constants.EASY_LABEL); font.setColor(Color.BLACK); font.draw( batch, Constants.EASY_LABEL, Constants.EASY_CENTER.x, Constants.EASY_CENTER.y + easyLayout.height / 2, 0, Align.center, false); final GlyphLayout mediumLayout = new GlyphLayout(font, Constants.MEDIUM_LABEL); font.draw( batch, Constants.MEDIUM_LABEL, Constants.MEDIUM_CENTER.x, Constants.MEDIUM_CENTER.y + mediumLayout.height / 2, 0, Align.center, false); final GlyphLayout hardLayout = new GlyphLayout(font, Constants.HARD_LABEL); font.draw( batch, Constants.HARD_LABEL, Constants.HARD_CENTER.x, Constants.HARD_CENTER.y + hardLayout.height / 2, 0, Align.center, false); batch.end(); }
@Override public void show() { // Initialize and create viewport and camera viewport.apply(); shapeCreator = new ShapeRenderer(); myBatch = new SpriteBatch(); user_locations = new ArrayList<Vector2>(); set_up_positions(); // Create stage game_stage = new Game_Stage(); game_stage.setViewport(viewport); // Sprite creation card_back = new Sprite(new Texture("card_images/vertical_cardback.png")); card_back.setPosition(user_locations.get(13).x, user_locations.get(13).y); // set input processor to the main menu stage Gdx.input.setInputProcessor(game_stage); }