Hi,
I made this simple jsfiddle to explain my problem :
When you set various scale to static body, the size of the body is not equal to the size of the sprite.
How do you fix that ? (setOrigin si well on .5 and normally the size of the body adjust automatically the size of the sprite ???).
Thanks a lot.
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'phaser-example',
physics: {
default: 'arcade',
arcade: {
debug: true
}
},
scene: {
preload: preload,
create: create
}
};
var sprite;
var group;
var game = new Phaser.Game(config);
function preload() {
this.load.image('mushroom', 'assets/sprites/mushroom2.png');
this.load.image('ball', 'assets/sprites/shinyball.png');
}
function create() {
sprite = this.physics.add.image(400, 300, 'mushroom');
group = this.physics.add.staticGroup({
key: 'ball',
frameQuantity: 30,
scale: Math.random(1, 4)
});
group.children.each(function (sprite) {
sprite.setScale(Math.random(3, 8));
sprite.setOrigin(.5)
}, this);
Phaser.Actions.PlaceOnRectangle(group.getChildren(), new Phaser.Geom.Rectangle(84, 84, 616, 416));
group.refresh();
sprite.setVelocity(100, 200).setBounce(1, 1).setCollideWorldBounds(true).setGravityY(200);
this.physics.add.collider(sprite, group);
}