Jump to content

difference of physicsBodyType = Phaser.Physics.ARCADE AND game.physics.arcade.enable(platforms); AND


Beyb26
 Share

Recommended Posts

Hello. I'm really confused about this, what is really the difference of these 3 enabling method of physics body in Phaser?

object.physicsBodyType = Phaser.Physics.ARCADE;

game.physics.arcade.enable(object); 

 game.physics.enable(object, Phaser.Physics.ARCADE);

 

Are they really the same?

Link to comment
Share on other sites

You need to remember the difference between a Group and a Sprite.

// Group#enableBody: When a sprite is added to this group, give it a physics body.
group.enableBody = true;
// Group#physicsBodyType: When `enableBody` is on, add bodies of this type.
group.physicsBodyType = Phaser.Physics.ARCADE; // (default)

// Add a physics body to a sprite or all the sprites in a group.
// All forms are equivalent, so use whichever you prefer.
physics.arcade.enable(groupOrSprite);
physics       .enable(groupOrSprite, Phaser.Physics.ARCADE);
physics       .enable(groupOrSprite, /* default: ARCADE */);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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