Hello I’m new in Phaser 3 and i fiddle with it’ s a plain example sketch
function create ()
{
this.matter.world.setBounds(0, 0, 800, 590, 32, true, true, false, true);
Here I get cannot read property world undefined
I use this in my index.html
I made the code more simple with the same result Phaser 3 does not know the Object matter.
If I do this with the complex index.html the example balls in physics it works. I also altered it to the latest Version 2.24.1
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/phaser@3.24.1/dist/phaser-arcade-physics.min.js"></script>
</head>
<body>
<script>
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#1d1d1d',
parent: 'phaser-example',
physics: {
default: 'matter',
matter: {
enableSleeping: true
}
},
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload ()
{
this.load.image('ball', 'assets/sprites/pangball.png');
}
function create ()
{
this.matter.world.setBounds(0, 0, 800, 600, 32, true, true, false, true); // Here is the problem
// Add in a stack of balls
for (var i = 0; i < 64; i++)
{
var ball = this.matter.add.image(Phaser.Math.Between(100, 700), Phaser.Math.Between(-600, 0), 'ball');
ball.setCircle();
ball.setFriction(0.005);
ball.setBounce(1);
}
}
</script>
</body>
</html>
I see the problem. Phaser arcade physics version doesn’t contain matter physics, that’s why matter is undefined. You should use the whole library or a custom version with matter physics imported.