Hello.
I’m using Phaser 3 and the official example from the website. The same sprites and the same platforms.
The platforms are created with the method staticGroup()
platforms = this.physics.add.staticGroup();
And I’m storing one of those rigs in a variable so I can manipulate its properties:
var test_platform = platforms.create(100, 100, 'ground');
To modify the height and width, I am using these properties:
test_platform.displayHeight = 100;
test_platform.displayWidth = 100;
To modify the collision edges, I am using the setSize() method
test_platform.body.setSize(80, 80)
If I run the game, the collision edges appear at different coordinates than the object:
I read that I have to refresh the state of the object using the refreshBody() function, so I’m running
test_platform.refreshBody()
When doing this, the coordinates of the collision edges are placed at the correct coordinates, but the measurements are adapted to the size of the body, and not the ones I set with the setSize(80,80) function.
Full code:
var test_platform = platforms.create(setXFromCenter(0), setYFromCenter(0), 'ground');
test_platform.displayHeight = 100;
test_platform.displayWidth = 100;
test_platform.body.setSize(80, 80);
test_platform.refreshBody();
Would anyone know how to modify the size of the body and at the same time modify the size of the collision edges?
Thanks.