-
Notifications
You must be signed in to change notification settings - Fork 9
Action Feedback Component
First see Components.
The ActionFeedbackComponent
is a vital component in our game development project responsible for generating action feedback alerts based on entity events. These alerts are visually distinctive and are created using the AlertUIComponent
.
The primary purpose of the ActionFeedbackComponent
is to create and display customizable warning alerts in response to specific events or actions within the game. These alerts help convey important information, warnings, or notifications to the player, enhancing the overall gaming experience.
The ActionFeedbackComponent
class does not have any custom constructors as it inherits from the Component
class, and its initialization is handled by the parent class.
To effectively use the ActionFeedbackComponent
, follow these steps:
-
Create an Entity with ActionFeedbackComponent: Instantiate an entity in the game and add the
ActionFeedbackComponent
to it. This component will enable you to trigger and display custom warning alerts on this entity.Entity yourEntity = new Entity(); yourEntity.addComponent(new ActionFeedbackComponent());
-
Adding Event Listeners: The
ActionFeedbackComponent
automatically adds event listeners to the entity. Two specific events can be used to trigger alerts:-
"displayWarning"
: Displays an alert at the entity's current position. -
"displayWarningAtPosition"
: Displays an alert at a specified position.
You can trigger these events to display alerts as needed:
// Display a warning alert at the entity's current position. yourEntity.getEvents().trigger("displayWarning", "Your alert message here"); // OR Vector2 position = new Vector2(x, y); // Specify the position where the alert should be displayed. yourEntity.getEvents().trigger("displayWarningAtPosition", "Your alert message here", position);
-
-
Customization: The alerts displayed by the
ActionFeedbackComponent
are created using theAlertUIComponent
. You can customize the appearance and behavior of these alerts by modifying the properties of theAlertUIComponent
. This includes changing text color, background color, and other visual aspects.
Here's a simple example demonstrating how to use the ActionFeedbackComponent
to create and display a warning alert:
Entity playerEntity = new Entity();
playerEntity.addComponent(new ActionFeedbackComponent());
// Trigger a warning alert at the player's current position.
playerEntity.getEvents().trigger("displayWarning", "Dangerous area ahead!");
By following these steps, you can seamlessly integrate the ActionFeedbackComponent
into your feature, providing informative and visually appealing alerts to enhance the player's gaming experience, all powered by the AlertUIComponent
.
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files