phaser icon indicating copy to clipboard operation
phaser copied to clipboard

scene plugin install failure

Open Lunalyst opened this issue 9 months ago • 4 comments

Version

  • Phaser Version: 3.80.1
  • Operating system: windows 10
  • Browser: chrome

Description

i found an issue with phaser.js . it was a issue loading some plugins. as an example the animated tiles plugin would not load properly because if line 126250 " pluginManager.installScenePlugin(systemKey, window[this.key], sceneKey, this.loader.scene, true);". if this line is change to "pluginManager.installScenePlugin(systemKey, Function(return ${this.key})(), sceneKey, this.loader.scene, true);" then the plugin works correctly. the script this resides in is here : https://github.com/phaserjs/phaser/blob/e337b6e4d13eb1979af06fe1ccf001b5174f0a47/src/loader/filetypes/PluginFile.js#L114

Example Test Code

code can be found at the text links below.

Additional Information

here is the plugin that was having trouble working. https://phaser.discourse.group/t/phaser-3-5-animated-tiles-tiled/11148

phaser without fix.txt

phaser with fix.txt

defaultScene.txt

Lunalyst avatar Apr 25 '24 06:04 Lunalyst

What's the code you used when the animated tiles plugin wouldn't load properly?

samme avatar Apr 25 '24 16:04 samme

the code I was using the animated tile plugin was my own game project. specifically my default scene class which is a class that builds of the scene object. specifically it was this.load.scenePlugin({ key: 'AnimatedTiles', url: 'lib/vendors/AnimatedTiles.js', sceneKey: 'AnimatedTiles' });

Lunalyst avatar Apr 25 '24 23:04 Lunalyst

load.scenePlugin() only works if the key is a property of window after the plugin script loads. The plugin author has to write it that way, e.g.,

window.AnimatedTiles = AnimatedTiles;

You can instead load the plugin script as a <script> (or even import it) and then pass the plugin class to the game config.

samme avatar Apr 26 '24 00:04 samme

thank you for the suggestion, i will give that a try.

Lunalyst avatar Apr 26 '24 01:04 Lunalyst