I’m trying to add a single tile from a tilemap, here is my code :
//LEVEL TILEMAP
const map = this.make.tilemap({ key: 'map' });
const tileset = map.addTilesetImage('pixel-adventure', 'tiles');
this.plateforms = map.createStaticLayer('Plateforms', tileset, 0, 0).setScale(1);
this.plateforms.setCollisionByExclusion(-1, true);
//LEVEL OBJECTS
//Sticks
this.sticks = this.physics.add.group({
allowGravity: false,
immovable: true
});
// Let's get the sticks objects, these are NOT sprites
const sticksObjects = map.getObjectLayer('sticks')['objects'];
// Now we create sticks in our sprite group for each object in our map
sticksObjects.forEach(sticksObject => {
// Add new platforms to our sprite group, change the start y position to meet the platform
console.log(sticksObject);
let stick = this.sticks.create(sticksObject.x, sticksObject.y, tileset); //ERROR IS HERE
});
Hi, It’s not my case, because in your example the coin is loaded separately, in my case i have on tile map for the level and the elements like box, platforms, etc…
Exact sorry, i didn’t see the load coin spritesheet.
I’m pretty sure to already read an answer to your question, but didn’t find it…
If i remember well, @samme gave the solution.
So i think your key is ‘tiles’ based on how you created the tileset and then the index that represents a stick you’ll have to look up in Tiled, I think it is “id”. Use the index number as the frame parameter so if your stick tile index is 34: