How to use multiple physics?

const config = {
  type: Phaser.CANVAS,
  scale: {
    parent: 'game-container',
    mode: Phaser.Scale.FIT,
    autoCenter: Phaser.Scale.CENTER_BOTH,
    width: window.innerWidth, 
    height: window.innerHeight,
  },
  backgroundColor: '#000c1f',
  parent: 'game-container',
  scene: [Preload, Boot, Main, Over],
  physics: {
    default: 'arcade,matter',
      arcade: {
          debug: true,
          gravity: {
            y: 200
          }
      },
      matter: {
        debug: true,
        gravity: { y: 0.5 }
    }
  }
}; 
const game = new Phaser.Game(config);

As you can see i have multiple scene, now how do i use multiple phsyics in this scenario ?

hello @sachinkiranti

https://labs.phaser.io/index.html?dir=physics/multi/&q=

:slight_smile:

Thank you . It’s using a single scene and i had multiple scenes . Anyway i solved it ! :blush:

export default class Main extends Phaser.Scene {
    constructor (config) {
        super({
            key: 'Main',
            physics: {
                default: 'arcade',
                  arcade: {
                      debug: true,
                      gravity: {
                        y: 200
                      }
                  },
                  matter: {
                    debug: true,
                    gravity: { y: 0.5 }
                }
            },
        });
    }
}
1 Like