Setting Size of Collider/Boundaries

I want to set the size of an collider of a whole group. Every Object should be smaller as it seems on the screen.

So i know i have to use : MyObject.setSize(width,height)

but i can’t implement it into my code like i need to.

1.)this works---->

this.bananaGroup = this.physics.add.group();
      this.bananaGroup.create(400, 0, 'banana').setScale(0.5).setSize(20, 20);

2.)but i need also this Calculation there:

 var bananaGroup = this.physics.add.group({
     key: 'banana',
 -->    repeat: 1,
  -->  setXY: { x: (Phaser.Math.Between(150, 800)), y: 0, stepX: 70 }
   });

Two questions: How can i put a Function Call like .SetSize into the second example?

How can i put the math into the first example?

How could i change the Shape of the object and not only the size?

var bananaGroup = this.physics.add.group({
  // …
  createCallback: function (banana) {
    banana.setBodySize(20, 20);
  }
}

Arcade Physics has only two shapes, rectangle and circle. You can position the body shape on the sprite with body.setOffset().

1 Like

so its from the middle of the sprite to x, y?

and how can i change it to circle?

is it possible to do the Math in brackets for the property, because then i think it would like that:

this.bananaGroup = this.physics.add.group();
      this.bananaGroup.create(400, 0, {math?} 'banana').setScale(0.5).setSize(20, 20).setBodySize(20,20);

The body offset is from the top-left of the sprite texture.

banana.setCircle(radius, offsetX, offsetY);