docsReading time: 3 minutes
General
Basics
- Getting Started
- Game API
- Input API
- Configuration
- Tile Maps
- Resource Management
- Entity Framework
- Control Entities
- User Interface
- utiLITI
- Deployment
- Savegames
- Libraries and Tools
- Glossary
Advanced
- The Particle System
- Dynamic Lighting
- Static Lighting
- Performance Optimization
- Custom MapObjectLoaders
- String Localization
- Object Serialization
- Utility Classes
- Network Communication
- Advanced Entity Knowledge
Tutorials
Annotations for Static Information
LITIENGINE uses Java annotations to define static entity properties. These annotations provide metadata that is applied when entities are instantiated from map objects.
Available Annotations
@EntityInfo
Basic entity configuration:
@EntityInfo(
width = 32, // Entity width in pixels
height = 32, // Entity height in pixels
renderType = RenderType.NORMAL // Rendering layer
)
public class MyEntity extends Entity {
// ...
}| Properties: | Property | Type | Description |
|---|---|---|---|
width | int | Entity width (pixels) | |
height | int | Entity height (pixels) | |
renderType | RenderType | Layer for rendering |
@CollisionInfo
Collision detection configuration:
@CollisionInfo(
collision = true, // Enable collision
collisionBoxWidth = 28, // Collision box width
collisionBoxHeight = 28, // Collision box height
collisionBoxAlign = Align.CENTER, // Horizontal alignment
collisionBoxValign = Valign.MIDDLE // Vertical alignment
)
public class Wall extends CollisionEntity {
// ...
}| Properties: | Property | Type | Description |
|---|---|---|---|
collision | boolean | Enable/disable collision | |
collisionBoxWidth | int | Collision box width | |
collisionBoxHeight | int | Collision box height | |
collisionBoxAlign | Align | Horizontal: LEFT, CENTER, RIGHT | |
collisionBoxValign | Valign | Vertical: TOP, MIDDLE, BOTTOM | |
collisionType | Collision | STATIC, DYNAMIC, ANY, NONE |
@MovementInfo
Movement properties for mobile entities:
@MovementInfo(
velocity = 100, // Pixels per second
acceleration = 50, // Acceleration rate
deceleration = 50, // Deceleration rate
turnOnMove = true // Face movement direction
)
public class Enemy extends Creature {
// ...
}| Properties: | Property | Type | Description |
|---|---|---|---|
velocity | float | Maximum speed (pixels/sec) | |
acceleration | float | Speed increase rate | |
deceleration | float | Speed decrease rate | |
turnOnMove | boolean | Auto-face movement direction |
@CombatInfo
Combat and health configuration:
@CombatInfo(
hitpoints = 100, // Maximum HP
team = 1, // Team identifier
isIndestructible = false, // Cannot be damaged
isTarget = true // Can be targeted
)
public class Player extends Creature {
// ...
}| Properties: | Property | Type | Description |
|---|---|---|---|
hitpoints | int | Maximum hitpoints | |
team | int | Team ID for friend/foe | |
isIndestructible | boolean | Immune to damage | |
isTarget | boolean | Can be targeted by abilities |
@AnimationInfo
Animation configuration:
@AnimationInfo(
spritePrefix = "player", // Spritesheet name prefix
spriteBatched = true // Use sprite batching
)
public class Player extends Creature {
// ...
}| Properties: | Property | Type | Description |
|---|---|---|---|
spritePrefix | String | Prefix for spritesheet lookup | |
spriteBatched | boolean | Enable sprite batching |
@AbilityInfo
Ability configuration (see Ability Framework):
@AbilityInfo(
cooldown = 1000, // Milliseconds between uses
duration = 500, // Execution duration
value = 100, // Custom value (damage, etc.)
range = 200 // Maximum range
)
public class Fireball extends Ability {
// ...
}Combining Annotations
Use multiple annotations for complete entity configuration:
@EntityInfo(width = 18, height = 18)
@MovementInfo(velocity = 70, acceleration = 10)
@CollisionInfo(collisionBoxWidth = 14, collisionBoxHeight = 16, collision = true)
@CombatInfo(hitpoints = 50, team = 1)
@AnimationInfo(spritePrefix = "gurknukem")
public class Player extends Creature {
public Player() {
super("gurknukem");
}
}Annotation vs Runtime Configuration
Annotations define static defaults that can be overridden at runtime:
@EntityInfo(width = 32, height = 32)
@MovementInfo(velocity = 100)
public class Enemy extends Creature {
public void speedBoost() {
// Override annotation value at runtime
this.setVelocity(200);
}
}Map Object Override
Properties set in the Tiled editor or utiLITI can override annotation defaults:
// Annotation provides defaults
@MovementInfo(velocity = 50)
// Map object can specify custom velocity
// This overrides the annotation value when loadedCreating Custom Annotations
Define custom annotations for game-specific data:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface EnemyInfo {
int aggroRange() default 200;
int xpReward() default 10;
String[] lootTable() default {};
}
@EnemyInfo(aggroRange = 300, xpReward = 25)
public class Boss extends Creature {
// ...
}See Also
- Default Entity Types – Built-in entity classes
- Ability Framework – Ability annotations
- Custom Properties – Runtime property configuration
Last updated 2 months ago
Feedback / Collaborate
