Uncaught TypeError: this.physics is undefined

Hi everyone,
I’m trying to create a game with phaser (if wasn’t the case i will not here :stuck_out_tongue:)
I’m following this tutorial but when I want to create a group I’ve an error in my browser.

Uncaught TypeError: this.physics is undefined

I can’t understand why I’ve this error.

This is my javascript’s code

var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'game_2',
physics: {
    default: 'arcade',
    arcade: {
        gravity: { y: 300 },
        debug: false
    }
},
scene: {
    preload: preload,
    create: create,
    update: update
}
};
  var platforms;
  platforms = this.physics.add.staticGroup();
  platforms.create(50, 250, 'ground');                                                                                                                                                                          
  platforms.create(600, 400, 'ground');                                                                                                                                                                         
  platforms.create(750, 220, 'ground');                                                                                                                                                                         

  function preload () {
      this.load.image('sky', 'img/sky.png');
      this.load.image('ground', 'img/platform.png');
      this.load.image('star', 'img/star.png');
      this.load.image('bomb', 'img/bomb.png');
      this.load.spritesheet('dude', 'img/dude.png', { frameWidth: 32, frameHeight: 48 });
  }

  function create () {
      this.add.image(400, 300, 'sky');

  }

  function update () {
  }

  var game = new Phaser.Game(config);

If someone can tell me where I was wrong I will grateful

Thanks

This code should go in create:

  var platforms;
  platforms = this.physics.add.staticGroup();
  platforms.create(50, 250, 'ground');                                                                                                                                                                          
  platforms.create(600, 400, 'ground');                                                                                                                                                                         
  platforms.create(750, 220, 'ground');                                                                                                                                                                         

Thanks it’s work.

:grinning: :+1: