I need to use matter and arcade on different sprites

I read through the other posts and re-wrote a bunch of code, still nothing. I can get arcade to work, or I can get matter to work, but not both. One or the other is always undefined. Below is my config file. I tried rewriting the scene{} part instead of scene[], and that just made things worse.
I tried getting rid of the “default” line, and that killed it. I cannot put both in “default”, or am I missing the syntax to do so?

// set game configuration
let config = {
type: Phaser.AUTO,
width: 900,
height: 700,
scene: [preloadScene, titleScene, gameScene, gameoverScene],
pixelArt: false,
physics: {
default: ‘arcade’,
arcade: {gravity: {y: 1000},
// debug: true,
},

matter:{gravity:{y:.5}},
},
};

//create new game and send configuration
let game = new Phaser.Game(config)

1 Like

http://labs.phaser.io/view.html?src=src\physics\multi\arcade%20and%20matter.js

My guess is something is different there, because it is all one long scene in the example. My project has several different JS files for each scene.

It has to go in the scene config, not the game config.

So, let’s say I’m adding physics to “game.js”, how do I add a config for the scene and where does it go? Into game.js?

What does gameScene look like?

let gameScene = new Phaser.Scene(‘Game’);

gameScene.init = function(){

};
// create after preload
gameScene.create = function(){
};
gameScene.update = function(){
};

I can give you the full code if you need, but that is the framework for any scenes that I run. From there, I can do things like this.unicorn=this.physics.add.sprite() or this.matter.add.sprite(), but it never lets me use both.

let gameScene = new Phaser.Scene({
  key: 'Game',
  physics: {
    arcade: { gravity: { y: 1000 } },
    matter: { gravity: { y: 0.5 } }
  }
});
// etc.

Man, that was waaaaaaaaay too simple. So scenes are functions too. :sweat_smile: Thanks so much! It’s all working now.