# Differences between setSize/setOffset methods in Arcade Static Body and Dynamic Body

**URL:** <https://phaser.discourse.group/t/differences-between-setsize-setoffset-methods-in-arcade-static-body-and-dynamic-body/734>\
**Category:** Phaser 3\
**Created:** [January 13, 2019, 1:40am UTC](https://phaser.discourse.group/t/differences-between-setsize-setoffset-methods-in-arcade-static-body-and-dynamic-body/734 "2019-01-13T01:40:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackfreak](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jackfreak](https://phaser.discourse.group/u/jackfreak)\
**Post date:** [January 13, 2019, 1:40am UTC](https://phaser.discourse.group/t/differences-between-setsize-setoffset-methods-in-arcade-static-body-and-dynamic-body/734/1 "2019-01-13T01:40:11Z")

</div>

I was wondering why there’s a difference between the setSize and setOffset methods of dynamic and static bodies.

I was using a dynamic body on a sprite and figure I could try a static body since my sprite will not be moving, just colliding/overlapping. An then I run into these differences, for example my sprite is a coin (sort of) my player would collect, Im reducing the size of the body because it feels better than leaving it at the default (taking the size of the gameobject). Everything works as expected if I use a dynamic body, the setSize() method will reduce the body size and set the body’s center to coincide with the gameobject center:

![39](https://global.discourse-cdn.com/free1/uploads/phaser1/original/1X/197264746685b2ea85e9cb9f3a92c3ef9684bac4.png)

But when I make it a static body , and set the size of the body, it will not align with with the center of the gameobject even when leaving the offsetx and offsety parameter of the function to the default values. It will align to the top bottom of the gameobject’s frame.

![30](https://global.discourse-cdn.com/free1/uploads/phaser1/original/1X/184da153ca5478dbf502017cc1c33fa9ba9084c1.png)

I have to center the static body manually with something like:

```
// Within a Phaser.Physics.Arcade.Sprite    
this.body.setSize(15, 15);

const dw = this.displayWidth / 2;
const dh = this.displayHeight / 2;

this.body.setOffset(dw - this.body.halfWidth, dh - this.body.halfHeight);

```

Any thoughts on why is this? Is it by design for some reason?

EDIT: I should add the setSize method has different signature in dynamic body than the static body.

> // In Phaser.Physics.Arcade.StaticBody  
> setSize: function (width, height, offsetX, offsetY)
> 
> // In Phaser.Physics.Arcade.Body  
> setSize: function (width, height, center)

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [January 13, 2019, 8:33pm UTC](https://phaser.discourse.group/t/differences-between-setsize-setoffset-methods-in-arcade-static-body-and-dynamic-body/734/2 "2019-01-13T20:33:14Z")

</div>

https://codepen.io/samme/embed/preview/ZVGKmv?default-tabs=js%2Cresult&height=300&host=https%3A%2F%2Fcodepen.io&slug-hash=ZVGKmv

I had a similar problem. If you look at [StaticBody#setOffset](https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.StaticBody.html#setOffset__anchor) it looks like `offset` is used only to adjust `position`, once. The only reliable method I found is to zero `offset` and then set `position` manually.

> I should add the setSize method has different signature in dynamic body than the static body.

> <https://github.com/photonstorm/phaser/issues/4213>
>
> \## Version
> 
> \* Phaser Version: 3.15.1
> 
> \## Description
> 
> Arcade.Components.Si…ze#setSize() should center the body on the texture when the \`center\` argument is true or omitted, but for static bodies this doesn't happen.
> 
> \## Example Test Code
> 
> On \<http://labs.phaser.io/edit.html?src=src\\physics\\arcade\\static%20body.js\> change line 37 to
> 
> \`\`\`javascript
> static1 = this.physics.add.staticImage(400, 100, 'bar').setSize(150, 150);
> \`\`\`
> 
> \## Additional Information
> 
> StaticBody#setSize(width, height, offsetX, offsetY) is being called with the wrong third argument.

---

<div class="post-metadata">

**Author:** ![jackfreak](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jackfreak](https://phaser.discourse.group/u/jackfreak)\
**Post date:** [January 13, 2019, 9:03pm UTC](https://phaser.discourse.group/t/differences-between-setsize-setoffset-methods-in-arcade-static-body-and-dynamic-body/734/3 "2019-01-13T21:03:08Z")

</div>

I should have taken a look to the issues before posting. Yes, it seems that the only reliable way is to position the body manually, which IMHO reduces the consistency of the API.  
Thanks for your answer!

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [February 6, 2019, 11:28pm UTC](https://phaser.discourse.group/t/differences-between-setsize-setoffset-methods-in-arcade-static-body-and-dynamic-body/734/4 "2019-02-06T23:28:51Z")

</div>

No worries, you’d have to read a bit farther into that issue to find it.

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [June 12, 2019, 8:23pm UTC](https://phaser.discourse.group/t/differences-between-setsize-setoffset-methods-in-arcade-static-body-and-dynamic-body/734/5 "2019-06-12T20:23:28Z")

</div>

> <https://github.com/photonstorm/phaser/pull/4589>
