Class TooltipSystem.TooltipComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.tooltip.TooltipSystem.TooltipComponent
- Enclosing class:
TooltipSystem
Component that handles tooltip detection and triggering.
Add this component to any entity that should display a tooltip when the player approaches.
The component automatically:
- Creates a HitboxComponent if the entity doesn't have one
- Detects when the player enters/exits the trigger area
- Triggers global events that TooltipDisplay listens for
Usage examples:
- Basic: new TooltipComponent("Press E to interact")
- With style: new TooltipComponent("Dangerous!", TooltipStyle.WARNING)
- With custom area: new TooltipComponent("Boss", TooltipStyle.WARNING, 4.0f, 3.0f)
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionTooltipComponent
(String text) Creates a tooltip with default style and auto-sized trigger areaTooltipComponent
(String text, TooltipSystem.TooltipStyle style) Creates a tooltip with custom style and auto-sized trigger areaTooltipComponent
(String text, TooltipSystem.TooltipStyle style, float widthMultiplier, float heightMultiplier) Creates a tooltip with custom style and trigger area size -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Called when the entity is created and registered.void
dispose()
Called when the component is disposed.getStyle()
Gets the tooltip stylegetText()
Gets the tooltip text.Gets the trigger zone entity for manual spawning if neededvoid
update()
Called once per frame of the game, and should be used for most component logic.Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
TooltipComponent
Creates a tooltip with default style and auto-sized trigger area- Parameters:
text
- The text to display in the tooltip
-
TooltipComponent
Creates a tooltip with custom style and auto-sized trigger area- Parameters:
text
- The text to display in the tooltipstyle
- The visual style for the tooltip
-
TooltipComponent
public TooltipComponent(String text, TooltipSystem.TooltipStyle style, float widthMultiplier, float heightMultiplier) Creates a tooltip with custom style and trigger area size- Parameters:
text
- The text to display in the tooltipstyle
- The visual style for the tooltipwidthMultiplier
- Multiplier for trigger area width (relative to entity)heightMultiplier
- Multiplier for trigger area height (relative to entity)
-
-
Method Details
-
getText
Gets the tooltip text.- Returns:
- the text displayed in the tooltip
-
getStyle
Gets the tooltip style- Returns:
- the style of the tooltip
-
create
public void create()Description copied from class:Component
Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished. -
update
public void update()Description copied from class:Component
Called once per frame of the game, and should be used for most component logic. Not called if component is disabled. -
getTriggerZoneEntity
Gets the trigger zone entity for manual spawning if needed- Returns:
- the trigger zone entity, or null if not created
-
dispose
public void dispose()Description copied from class:Component
Called when the component is disposed. Dispose of any internal resources here.
-