Hi, I’m new to this world and have been learning Phaser 3 for a few weeks. Right now I’m taking a tutorial about physics and collisions, but I have a doubt, the tutorial has this:
physics: {
default: 'arcade',
arcade: {
gravity: { y: 200 },
enableBody: true,
}
},
But never explain what enableBody: true does. I commented and set this line to false, and tested, but in the example, the collisions still work… is something needed in the example?
function preload() {
this.load.image('bug1', 'https://content.codecademy.com/courses/learn-phaser/physics/bug_1.png');
this.load.image('bug2', 'https://content.codecademy.com/courses/learn-phaser/physics/bug_2.png');
this.load.image('bug3', 'https://content.codecademy.com/courses/learn-phaser/physics/bug_3.png');
this.load.image('platform', 'https://content.codecademy.com/courses/learn-phaser/physics/platform.png');
this.load.image('codey', 'https://content.codecademy.com/courses/learn-phaser/physics/codey.png');
}
const gameState = {};
function create() {
gameState.player = this.physics.add.sprite(225, 440, 'codey').setScale(.5);
// Añade el GameObject.staticGroup para actuar como plataforma
const platforms = this.physics.add.staticGroup();
// Crea para dicho GameObject.staticGrup la imagen que se usara y su posición x,y
platforms.create(225, 510, 'platform');
}
function update() {
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 500,
backgroundColor: "b9eaff",
physics: {
default: 'arcade',
arcade: {
gravity: { y: 200 },
enableBody: true,
}
},
scene: {
preload,
create,
update
}
};
const game = new Phaser.Game(config);