Hello, I’m new to Phaser, still trying to figure out the fundamentals of Tilemaps.
One thing I can’t figure out despite hours of research and trial and errors, is to create a tilemap containing multiple data layers, created from arrays.
Consider the following arrays (reduced size for the sake of the discussion):
const data1 = [
[1, 1, 1, 1],
[1, 0, 0, 1],
[1, 0, 0, 1],
[1, 1, 1, 1],
];
const data2 = [
[0, 0, 0, 0],
[0, 0, 2, 0],
[0, 0, 2, 0],
[0, 0, 0, 0],
];
Consider that these will be procedurally generated, so using Tiled is out of the question.
How would I go about and create a single tilemap object that contain 2 layers, each with a different data array?
Importing from Tiled allows for multiple layers so I’m pretty sure it is possible to do it in a more dynamic way, only exemples seem to be non-existent. So far the exemples I’ve seen only provide one array at initialization:
scene.make.tilemap({
data: [...],
tileWidth:32,
tileHeight:32,
});
This effectively creates one layer with the provided data.
At this point, I’ll probably create as many tilemaps as I have data arrays, and visually align them to get the same effect. However it feels like that would not be the best approach, given the capabilities of Tilemaps.
Thank you.