import Phaser from 'phaser'

import Player from '../sprites/Player'

import Curve from '../plugins/Curve'

export default class extends Phaser.State {
  create () {
    this.game.world.enableBody = true
    this.game.physics.startSystem(Phaser.Physics.ARCADE)
    this.game.plugins.add(Curve, [50, 0, 0, 0, 50])

    this.map = this.game.add.tilemap('earth_travel')
    this.map.addTilesetImage('lofi_environment_4x', 'tiles')

    // Add both the background and ground layers. We won't be doing anything
    // with the GroundLayer though
    this.backgroundLayer = this.map.createLayer('backgroundlayer')

    // Add the sprite to the game and enable arcade physics on it
    var playerSpawnX = this.game.world.centerX / 2;

    this.player = new Player(this.game, playerSpawnX, this.game.world.centerY)
    this.world.add(this.player)

    // Make the camera follow the sprite
    this.game.camera.follow(this.sprite)
  }

  update () {
    if (this.player.x > this.game.world.width) {
      this.state.start('Fight')
    }
  }
}

import Phaser from 'phaser'

import Player from '../sprites/Player'

import Curve from '../plugins/Curve'

export default class extends Phaser.State {
  create () {
    this.game.world.enableBody = true
    this.game.physics.startSystem(Phaser.Physics.ARCADE)
    this.game.plugins.add(Curve, [50, 0, 0, 0, 50])

    this.map = this.game.add.tilemap('earth_travel')
    this.map.addTilesetImage('lofi_environment_4x', 'tiles')

    // Add both the background and ground layers. We won't be doing anything
    // with the GroundLayer though
    this.backgroundLayer = this.map.createLayer('backgroundlayer')
    this.backgroundLayer.resizeWorld()

    // Add the sprite to the game and enable arcade physics on it
    var playerSpawnX = this.game.world.centerX / 2;

    this.player = new Player(this.game, playerSpawnX, this.game.world.centerY)
    this.world.add(this.player)

    // Make the camera follow the sprite
    this.game.camera.follow(this.player)
  }

  update () {
    if (this.player.x > this.world.width) {
      this.state.start('Fight')
    }
  }
}

Fix world size and camera follow.
Fix world size and camera follow.
