IsaacM

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. Hi ! I have a problem when i want to import this line : game.physics.startSystem(Phaser.Physics.ARCADE); and i have this error : game.js:32 Uncaught TypeError: Cannot read property 'startSystem' of undefined my main.js is that : var game = new Phaser.Game( { type: Phaser.AUTO, // Which renderer to use width: 500, // Canvas width in pixels height: 500, // Canvas height in pixels parent: "game-container", // ID of the DOM element to add the canvas to scene: { preload: preload, create: create, update: update }, physics: { default: "arcade", arcade: { gravity: { y: 0 } // Top down game, so no gravity } } }); let player; function preload() { this.load.image("perso", "../assets/images/perso.png"); this.load.image("tiles", "../assets/tilesets/atlas.png"); this.load.tilemapTiledJSON("map", "../assets/tilemaps/map.json"); } function create() { game.physics.startSystem(Phaser.Physics.ARCADE); const map = this.make.tilemap({ key: "map" }); // Parameters are the name you gave the tileset in Tiled and then the key of the tileset image in // Phaser's cache (i.e. the name you used in preload) const tileset = map.addTilesetImage("atlas", "tiles"); // Parameters: layer name (or index) from Tiled, tileset, x, y const fond = map.createStaticLayer("fond", tileset, 0, 0); const worldLayer = map.createStaticLayer("element", tileset, 0, 0); worldLayer.setCollisionBetween(12, 44); worldLayer.setCollisionByProperty({ collides: true }); const debugGraphics = this.add.graphics().setAlpha(0.75); const spawnPoint = map.findObject("Objects", obj => obj.name === "spawnPoint"); player = this.physics.add.sprite(spawnPoint.x, spawnPoint.y, "perso"); const spawnPointM = map.findObject("ObjectsPosM", obj => obj.name === "spawnPointM"); monster = this.physics.add.sprite(spawnPointM.x, spawnPointM.y, "perso"); this.physics.add.collider(player, worldLayer); this.cameras.main.startFollow(player, true, 0.08, 0.08); this.cameras.main.setZoom(1.5); } function update(time, delta) { var speed = 300 // Stop any previous movement from the last frame player.body.setVelocity(0); cursors = this.input.keyboard.createCursorKeys() // Horizontal movement if (cursors.left.isDown) { player.body.setVelocityX(-100); } else if (cursors.right.isDown) { player.body.setVelocityX(100); } // Vertical movement if (cursors.up.isDown) { player.body.setVelocityY(-100); } else if (cursors.down.isDown) { player.body.setVelocityY(100); } // Normalize and scale the velocity so that player can't move faster along a diagonal player.body.velocity.normalize().scale(speed); } Im sorry if my english is bad, im a french student...