Post

Visualizzazione dei post con l'etichetta button

User Interface - Updating when triggered

Immagine
Here we are, we have almost finished our work on the User Interface. In the previous post  we created the building blocks to update the interface when a DrawUI event is triggered from code. Now let's see how to actually draw the changes on screen. Let's say we have 2 health points left out of 3. Then I want to draw 2 green ships icons, and 1 grey ship, like this: I have to create 2 FOR loops: the first one from 1 to lives  for the green ships; the second one from life + 1  to maxLives  for the grey ships. (We created these variables here , in case you don't remember). It could be easily done by code, but since I'm working on the HUD inside its blueprint, I will try to write this in the graph editor. We already added 2 WrapBoxes to the HUD, one for health points and one for resources; the first step is to remove any object inside each box, so we can start from empty containers. Unreal gives us the useful method Clear Children, that we're go...

User interface - Adding functionalities

Immagine
In the previous post we created the layout for our user interface. Before going on with the work on it, I want to add some useful stuff to C++ code. I decided to store all informations about the player status (health points, resources, etc.) in the PlayerController class, becuse it seems the most logic place for them. So I'm adding a bunch of new variables: lives:  the number of actual health points left; maxLives:  the maximum number of available health points (it's 3 for now); resources:  the number of collected resources; maxResources:  the maximum number of collectible resources (let's say it's our cargo space, and I'm setting it to 5 for now). All these variables are created with the UPROPERTY macro, so that they're visible from the Blueprints, and can be used to modify the User Interface widget. I'm also going to create some new UFUNCTION methods that will handle the events coming from the User Interface buttons: selectOpti...

User Interface - Displaying a HUD

Immagine
Now that we have collisions, I think it's time to show some informations to the player: let's implement a user interface! The first step was to put down a mockup of my idea in Photoshop. I modeled some simple panels in Blender and I placed them around in the screen, trying to choose places where they don't cover any tile of the grid: On the left, I have a button to select the game options (this will also pause the game). On the right, from top to bottom: - Health panel. In green, we have the current health points left, and in grey the max number of health points (I plan to increase them to 4 in advanced levels, that's why I left some space on the right). - Resources panel. In yellow, the collected resources, and in grey the max collectable ones. - Repair button. Pressing this button, the ship will be repaired (if there are enough resources available). - Mine button. This button will deploy a mine. That's all I need for now, so I created ...