phaser-arcade-slopes icon indicating copy to clipboard operation
phaser-arcade-slopes copied to clipboard

Errors: "Unresolved slope type 'r' / Slope type r not defined", "tilemapLayer.getTileOffsetX is not a function"

Open SHG42 opened this issue 4 years ago • 4 comments

I'm trying to set up a basic Phaser CE project with the arcade-slopes plugin. I have a Phaser 3 project where I'm handling sloped platforms with MatterJS, but Arcade has some methods that would be very useful for this project, so I want to compare slope-handling in CE with the plugin to slope-handling in Phaser 3 with Matter.

I'm running the bare-bones Webpack template from the Phaser CE repo and I'm running the project with node through VS Code. I used the provided arcadeslopes tileset and followed the instructions on the main repo page for the plugin for setting up.

I have run into these two issues, and I'm not sure if it's a bug or just me making novice mistakes, LOL. (I've been learning Phaser3 for about half a year, and this is my first time using CE.)

  • "tilemapLayer.getTileOffsetX is not a function" : this error occurs when setting up a collider between the player sprite and the platform. It goes away if I comment out any lines of code related to the plugin.
  • "Unresolved slope type 'r' / Slope type r not defined" : this error occurs with or without the collider, it goes away if I comment out any lines of code related to the plugin.

Here are screenshots of the dev tools console, and you can view the complete source code at this Drive folder.

With plugin-related lines of code commented out With no collider With collider Could you please enlighten me as to what's going wrong here?

SHG42 avatar Apr 20 '20 16:04 SHG42

Hi! Thanks for reaching out.

At first glance of your error stack traces, I would assume it's caused by one of the following:

  • Tiled's tilemap data format has changed
  • The plugin is no longer compatible with the most recent versions of Phaser CE
  • The slope map has been registered with the plugin incorrectly

Without having looked at your code yet, I'd suggest trying to run your project with earlier versions of Phaser CE to see if it works. That would help you or I narrow it down. If it works in 2.10.x, for example, then it's likely an issue with your code, as that was the last version I tested the plugin with.

Hopefully I'll get some time to inspect your code, get it running, and figure out what's going wrong here.

hexus avatar May 03 '20 02:05 hexus

Hi, thanks for the reply! I managed to resolve this by switching from using phaser-arcade-slopes.min.js to using the regular phaser-arcade-slopes.js file, and that worked. I had already installed Phaser CE 2.10 before installing the plugin, as I'd noticed that the compatibility chart ended there, so I was definitely having this issue with 2.10.x installed. My code worked as expected without needing any further modifications once I switched the js file. As to why switching the js file resolved the issue... well, that's beyond the scope of my experience as a coder, so I'll leave that up to you! I would be curious to know what happened, though, if you get a chance to look into it.

SHG42 avatar May 14 '20 16:05 SHG42

Oh, interesting! So the minified version is the only one that causes a problem, without changing anything else? I'm pretty much just passing it through uglify, so that surprises me. Maybe uglify needs updating.

Indeed the compatibility chart ends at 2.10.x, but may well support some later versions okay. I simply haven't tested them. 😄 Mostly using Phaser 3 these days.

hexus avatar May 14 '20 22:05 hexus

Yep, it does seem that the minified file was causing the problem, which was very surprising to me as well. I had been going over my code with a fine-toothed comb trying to find mistakes, and I decided on a whim to try switching the files, and you can imagine my surprise when that did the trick.

Yeah, I had originally started this project in Phaser 3 (I just started learning Phaser last year, so I started with 3). Hadn't planned on needing to use CE, but I really wanted to use your plugin, LOL. I had been handling slopes with Matter and it was just not providing the results I wanted. I was actually quite shocked when I found out that Arcade doesn't handle slopes natively!

SHG42 avatar May 15 '20 16:05 SHG42