clik-engine API
    Preparing search index...

    Class TileEffects

    Registers gameplay effects triggered by tile properties. Check entities against tiles each frame for enter/stay/exit lifecycle.

    Usage:

    const effects = new TileEffects();
    effects.register({
    property: 'hazard', value: true,
    onStay: (entity, tx, ty, delta) => entity.getComponent('health')?.damage(10 * delta / 1000),
    });
    effects.register({
    property: 'ice', value: true,
    onEnter: (entity) => entity.getComponent('movement')?.setFriction(0),
    onExit: (entity) => entity.getComponent('movement')?.setFriction(0.5),
    });
    // In update: effects.check(entity, getTilePropertiesAt(entity.x, entity.y), delta);
    Index

    Constructors

    Accessors

    Methods

    • Check an entity against tile properties at its position.

      Parameters

      • entity: Entity

        The entity to check

      • tileProperties: Record<string, unknown>

        Properties of the tile at entity's position

      • tileX: number

        Tile grid X

      • tileY: number

        Tile grid Y

      • delta: number

        Frame delta in ms

      Returns void