hi i used Sharks code in old forum but the collision works but it creates only the static group on onespot
var overlapObjects = this.map.getObjectLayer('Overlap')['objects']; //my Object layer was called Overlap
let overlapObjectsGroup = this.game.physics.add.staticGroup({
});
let i = 0;
overlapObjects.forEach(object => {
let obj = overlapObjectsGroup.create(object.x, object.y, 'grass');
obj.setScale(object.width/32, object.height/32); //my tile size was 32
obj.setOrigin(0); //the positioning was off, and B3L7 mentioned the default was 0.5
obj.body.width = object.width; //body of the physics body
obj.body.height = object.height;
});
overlapObjectsGroup.refresh(); //physics body needs to refresh
console.log(overlapObjectsGroup);
this.game.physics.add.overlap(this.player, overlapObjectsGroup, this.test, null, this);
so i tried it on a tilempa layer grass for example and it creates the frame 30 times on the same spot?
How to code it so every tile get a new position?