Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scene plugin install failure #6800

Open
Lunalyst opened this issue Apr 25, 2024 · 4 comments
Open

scene plugin install failure #6800

Lunalyst opened this issue Apr 25, 2024 · 4 comments

Comments

@Lunalyst
Copy link

Lunalyst commented Apr 25, 2024

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 :

var plugin = pluginManager.install(this.key, window[this.key], start, mapping);

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

@samme
Copy link
Contributor

samme commented Apr 25, 2024

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

@Lunalyst
Copy link
Author

Lunalyst commented Apr 25, 2024

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 Lunalyst changed the title found and fixed a bug that prevents some plugins from being loaded. scene plugin install failure Apr 25, 2024
@samme
Copy link
Contributor

samme commented Apr 26, 2024

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.

@Lunalyst
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants