Package com.csse3200.game.components
Class PromptComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.PromptComponent
A component responsible for displaying a temporary prompt or tooltip
when player collides with another entity.
The prompt text and display duration are configured upon instantiation.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPromptComponent(String prompt, Float duration) Creates a new PromptComponent with the specified prompt text and display duration. -
Method Summary
Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Field Details
-
prompt
The text content of the prompt/tooltip to be displayed. -
duration
The duration, in seconds, for which the prompt will be displayed.
-
-
Constructor Details
-
PromptComponent
Creates a new PromptComponent with the specified prompt text and display duration.- Parameters:
prompt- The string content to display in the tooltip.duration- The time, in seconds, before the tooltip automatically disappears.
-
-
Method Details
-
create
public void create()Registers a listener for"onCollisionStart"events. When a collision starts, theonCollide(Entity)method is executed. -
onCollide
Handles collision events.Displays the stored
promptusing theTooltipSystemand schedules the tooltip to hide after the specifiedduration.- Parameters:
collector- The entity that has collided with this entity (and is thus the one "triggering" the prompt display).- Returns:
- true to indicate the collision event was handled.
-