Jump to content

Chendler
 Share

Recommended Posts

Hello, comunity and Richard.

 

When I create my player, I use the follows code:

 

creature = game.add.sprite(-500, -500, 'hero', 2, group);
game.physics.enable(creature, Phaser.Physics.ARCADE);
creature.body.gravity.y = 500;
creature.scale.set(xFactor, yFactor);
creature.body.offset.x = creature.body.width - creature.body.width * 0.8;
creature.body.width = creature.body.width * 0.8;

 

After creature.scale.set() phaser immedeately change creature.width, but doesn't change creature.body.width.

Then I change my creature.body.width to needed value, but after first update() run phaser set creature.body.width to updated creature.width. How I understood, it's because phaser update physics after each update() iteration.

 

 

Is it normal behavior?

 
Link to comment
Share on other sites

Unrelated tip:

creature.body.width - creature.body.width * 0.8;
is equivalent to

creature.body.width * 0.2;

 

I might (and most likely am) be wrong, but I think you should leave sprite.body alone. In the docs http://docs.phaser.io/Phaser.Physics.Arcade.Body.html#width, it says " The calculated width of the physics body.". So I don't think messing with it is the right way to go.

Link to comment
Share on other sites

Unrelated tip:

creature.body.width - creature.body.width * 0.8;

is equivalent to

creature.body.width * 0.2;

 

I might (and most likely am) be wrong, but I think you should leave sprite.body alone. In the docs http://docs.phaser.io/Phaser.Physics.Arcade.Body.html#width, it says " The calculated width of the physics body.". So I don't think messing with it is the right way to go.

 

Thanks for tip :)

Hm, I think it occurs (body.width auto update) because in my update() I have animation, frames update - body update, but I'm not sure.

 

Who knows right way to reduce boundig box size without sprite changes?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...