sendmenas Posted September 11, 2018 Share Posted September 11, 2018 Hi, I have created a Tiled map with object layer in it. this.objectLayer = this.map.createFromObjects('Object Layer 1', 1, {key: 'brick'} ); This creates an array of sprites, as expected. But when I check these sprites, I see that body is null. I want to add collider for the objects and I believe due to the reason that they have no body, this does not work. What I aim to do is to create walls, that after hit will shrink by 25% based on bullet direction. I successfully managed to do it on one brick without using Tiled map: // Created brick this.bricks = this.physics.add.staticGroup(); this.bricks.create(400, 300, 'brick'); // Added callback on hit this.physics.add.overlap(this.bricks, this.bullet, this.bulletBrickHit, null, this); // Changing brick size on hit bulletBrickHit(bullet, brick) { switch(bullet.direction) { case 'left': brick.setCrop(0, 0, brick.body.width - 25, brick.body.height); brick.setSize(brick.body.width - 25, brick.body.height); break; } } But I was thinking of using Tiled for map creation as it would be much faster to do it using it. So my questions are: Can I use Tiled objects for this? Or should I add all bricks manually, as Tiled is not for that? Maybe there is some other way how to do it "right"? Or maybe I am just missing something? I would really appreciate your help. Link to comment Share on other sites More sharing options...
sendmenas Posted September 15, 2018 Author Share Posted September 15, 2018 Is this very hard or very stupid question? Link to comment Share on other sites More sharing options...
kiemu Posted September 17, 2018 Share Posted September 17, 2018 On 9/15/2018 at 2:02 PM, sendmenas said: Is this very hard or very stupid question? Maybe not a lot people use Tiled. Link to comment Share on other sites More sharing options...
iKest Posted September 17, 2018 Share Posted September 17, 2018 bulletBrickHit(bullet, brick) { switch(bullet.direction) { case 'left': brick.setCrop(0, 0, brick.body.width - 25, brick.body.height); brick.setSize(brick.body.width - 25, brick.body.height); brick.refresh(); break; } } for create static layer see example: https://labs.phaser.io/edit.html?src=src\game objects\tilemap\static\create from objects.js Link to comment Share on other sites More sharing options...
Recommended Posts