Sure, the first step is I would add your armies and towers as sprites instead of a tile layer. In preload:
this.load.image('tower', 'path/to/tower.png');
this.load.image('army', 'path/to/army.png');
When you spawn them, you just need to use this instead of putTileAt:
this.add.sprite(x, y, 'tower');
If they need physics:
this.physics.add.sprite(x, y, 'tower');
In addition, I would add these all to an array. In create:
this.towers = [];
this.armies = [];
When you spawn your sprites, push them into these arrays:
this.towers.push(this.physics.add.sprite(x, y, 'tower'));
In update, you can iterate these arrays in real time now, and manipulate them as you please. What I suggested was to get the sprite body, calculate an offset and then add a status bar image. You can also add text. With a status bar, I would make a tile sprite with different tiles representing different stages of health, but you can also draw a status bar with stuff like this:
const rect = this.add.rectangle(200, 150, 200, 150, 0x00ff00);
rect.setStrokeStyle(4, 0x000000);
To iterate them in update:
this.towers.forEach((tower) => {
let ox = tower.x - 10;
let oy = tower.y -10;
this.add.sprite(ox, oy, 'statusbar');
this.add.text(ox, oy, {
fontFamily: "Arial",
fontSize: "16px",
color: "#ffffff"
}, '6');
});
I don’t know how you want to do the status bar logic. If it has to be completely dynamic (like they have 100 hit points and an enemy can take away any number of points per hit), then don’t use a sprite and just draw it, unless you want to make a tile sprite with 100 frames, which is possible!