{"size": 1267, "ext": "js", "max_stars_repo_path": "src/plugins/LuminusObjectMarker.js", "max_stars_repo_name": "nguoianphu/luminus-rpg", "max_stars_repo_stars_event_min_datetime": "2021-09-07T11:21:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-07T11:21:34.000Z", "max_issues_repo_path": "src/plugins/LuminusObjectMarker.js", "max_issues_repo_name": "nguoianphu/luminus-rpg", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plugins/LuminusObjectMarker.js", "max_forks_repo_name": "nguoianphu/luminus-rpg", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.5434782609, "max_line_length": 128, "alphanum_fraction": 0.5217048145}
import Phaser from 'phaser';

/**
 * @class
 */
export class LuminusObjectMarker {
    /**
     * Displays a marker on interactive objects.
     * @param { Phaser.Scene } scene Parent Scene.
     * @param { Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer} map Tile Map to get the markers from.
     */
    constructor(scene, map) {
        /**
         * Scene Context where it will create the markers.
         * @type { Phaser.Scene }  */
        this.scene = scene;
        /**
         * Tile Map to get the object from.
         * @type {Phaser.Tilemaps.Tilemap} */
        this.map = map;

        /**
         * Marker name.
         * @type { string }
         * @default
         */
        this.tiledObjectLayer = 'markers';

        /**
         * Interaction indicator Sprite name.
         * @type { string }
         * @default
         */
        this.markerSpriteName = 'question_mark';
    }

    create() {
        const infoObjects = this.map.getObjectLayer(this.tiledObjectLayer);
        infoObjects.objects.forEach((infoObj) => {
            this.scene.add
                .image(infoObj.x, infoObj.y, this.markerSpriteName)
                .setDepth(2);
        });
    }
}
