Now I have the following:
let tileset = this.add.graphics({ add: true, x: 0, y: 0 })
let color = new Phaser.Display.Color()
let len = 5
let size = 50
for (let i = 0; i < len; i++) {
tileset.lineStyle(2, 0x000000, 1)
tileset.fillStyle(color.random(50).color)
tileset.fillRect(i*size, 0, size, size)
tileset.strokeRect(i*size, 0, size, size)
}
tileset.generateTexture('myset', size*len, size)
How can I add a random number to the center of each rectangle to use this texture for a tilemap?
Like this: