I tried to write a loop, that loads the image from local path. For that i try to use Konva:
const playerLayer = new Konva.Layer();
var playerAmount = 1;
while (playerAmount < 6) {
var playerIcon = new Image();
var playerInstance = new Konva.Image({
x: 660,
y: 140,
image: playerIcon,
width: 32,
height: 32
});
playerIcon.src = "media/heroes/hero1.png";
playerLayer.add(playerInstance);
playerAmount++;
}
stage.add(playerLayer);
For some reason images don't appear.
What i checked:
You need to redraw the layer when an image is loaded:
playerIcon.onload = function() {
playerLayer.batchDraw();
}