TooltipModule
This module can be used to assign some data to an entity from the GraphicEntityModule. The data will be displayed in a tooltip when the mouse cursor hovers over the entity on screen.
You may change the assigned data of each entity once per game turn.
Import
⚠ This module requires the GraphicEntityModule to work.
Add the dependency in the pom.xml
of your project.
<dependency>
<groupId>com.codingame.gameengine</groupId>
<artifactId>module-tooltip</artifactId>
<version>${gamengine.version}</version>
</dependency>
And load the module in your config.js
.
import { GraphicEntityModule } from './entity-module/GraphicEntityModule.js';
import { TooltipModule } from './tooltip-module/TooltipModule.js';
export const modules = [
GraphicEntityModule,
TooltipModule
];
Usage
Referee.java
@Inject TooltipModule tooltips;
@Override
public void init() {
// adding a tooltip to an entity
tooltips.setTooltipText(myEntity, "the tooltip text linked to this entity");
// removing the tooltip from an other entity
tooltips.removeTooltipText(otherEntity);
// getting the tooltip text associated to an entity
String text = tooltips.getTooltipText(myEntity);
// in this case text will now be "the tooltip text linked to this entity"
}
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Suggested playgrounds