This is my first time using CE, I’ve been learning Phaser 3 for the past few months. I wanted to set up a simple CE project to try out the Phaser-Arcade-Slopes plugin, so I can compare it to handling slopes with MatterJS in P3. I followed the instructions on that page to set up my project, and I’ve been trying to follow this tutorial as well, although I don’t quite understand how he set up his convertTilemapLayer() statement.
I’m using the barebones Webpack boilerplate from the CE master branch repo’s Resources directory.
The problem shows up when I try to enable collision between the player sprite and the platform which has been converted to use the slopes plugin. If I remove the collider statement, the error goes away. The only other warning or error in the console is a source map error message, but that was there before I included the plugin. And based on my Googling on the source map error, as I understood it, the source map error shouldn’t be impacting the functioning of my game.
What could be causing this?
Here is a screenshot of the console error message.
I have the rest of my source code in this Drive folder, but here’s my index.js file so far:
import PIXI from ‘expose-loader?PIXI!phaser-ce/build/custom/pixi.js’;
import p2 from 'expose-loader?p2!phaser-ce/build/custom/p2.js';
import Phaser from 'expose-loader?Phaser!phaser-ce/build/custom/phaser-split.js';
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
this.game.load.tilemap('hexustiles', './assets/tilemaps/stage2-hexustiles.json', null, Phaser.Tilemap.TILED_JSON);
this.game.load.spritesheet('tiles', './assets/images/tilesets/arcade-slopes-16.png', 16, 16);
this.game.load.atlas('hero', './assets/spritesheets/hero.png', './assets/spritesheets/hero.json', Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
}
function create() {
this.game.physics.startSystem(Phaser.Physics.ARCADE);
this.game.plugins.add(Phaser.Plugin.ArcadeSlopes);
this.map = this.game.add.tilemap('hexustiles');
this.tiles = this.map.addTilesetImage('arcade-slopes-16', 'tiles');
this.platform = this.map.createLayer('hexus-tiles');
this.map.setCollisionBetween(1, 38, true, this.platform);
this.game.slopes.convertTilemapLayer(this.platform, 'arcadeslopes');
this.hero = this.game.add.sprite(50, 50, 'hero', 'adventurer-idle-00-1.3');
this.game.physics.arcade.enable(this.hero);
this.hero.body.gravity.y = 2000;
this.game.camera.follow(this.hero);
this.game.slopes.enable(this.hero);
this.controls = game.input.keyboard.createCursorKeys();
console.log(this.game.slopes, this.platform, this.tiles);
};
function update() {
this.game.physics.arcade.collide(this.hero, this.platform);
}