Crafting System Code Implementation Sprint Three - UQdeco2800/2022-studio-2 GitHub Wiki

Introduction

Crafting Menu Animations and Quantity Indicators

Implemented by @lyphng

This sprint, we focused more on the visual aspect of the game and making it look more polished. For the crafting system, this includes adding animations and icons to display the quantity of each item.

To show the quantity, the displayAmount function is called at each iteration of the inventory contents. The quantity is passed into the function and the corresponding image is displayed. A forever looping action of moving up and down is added to each icon.

Action upDown = Actions.forever(Actions.sequence(Actions.moveTo(matAmount.getX(), matAmount.getY()+4.5f,
                0.5f), Actions.moveTo(matAmount.getX(), matAmount.getY()-4.5f, 0.5f)));
matAmount.addAction(upDown);

The displayPopUp function is called when the user successfully crafts a weapon and appears by growing gradually bigger. After it reaches the correct size, the pop up disappears. This animation code is below.

Action popUpAction = Actions.sequence(Actions.sizeTo(142.5f, 47.5f, 0.5f),
                Actions.delay(0.5f), Actions.run(new Runnable() {
                    @Override
                    public void run() {
                        popUp.remove();
                    }
                }));
popUp.addAction(popUpAction);

Different Design for Each Map

The first part of displaying a different design for each map was detecting the map that the player is on. This is done by calling the gameAreaName which is set in the ForestGameArea and UndergroundGameArea classes. After that, displaying the different designs is a simple matter of using the respective images, an example of which is below.

craftMenu = new Image(new Texture(Gdx.files.internal(String.format("images/Crafting-assets-sprint1/" +
                "crafting table/crafting_inventory_lvl%d.png", gameLevel))));