Global plugins not mapped on scene when render type is Phaser.HEADLESS
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 40.3k
- Forks
- 7.2k
- PR merge metrics
- No merged PRs in 30d
Description
Version
- Phaser Version: 3.88-3.90
- Operating system: Windows/Linux (Not specific to any)
- Browser: Tested in Firefox/Chrome
Description
As of https://github.com/phaserjs/phaser/commit/8736f0e844c8f924bf129d9364468c2cfa8c250d, plugin keys are not correctly populated on scenes. e.g. a global plugin with a mapping of "test" is not available as scene.test
Example Test Code
This repros with the "global scene plugin" example with no changes other than swapping type to HEADLESS:
class TestPlugin extends Phaser.Plugins.BasePlugin {
constructor (pluginManager)
{
super(pluginManager);
}
wibble ()
{
console.log('hello');
}
}
var config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.HEADLESS,
parent: 'game-container',
width: 800,
height: 600,
plugins: {
global: [
{ key: 'TestPlugin', plugin: TestPlugin, start: false, mapping: 'test' }
]
},
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('elephant', 'assets/sprites/elephant.png');
}
function create ()
{
this.test.wibble(); // Error: this.test is undefined
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing Phaser's global scene plugin example with the supplied HEADLESS configuration and inspect commit 8736f0e844c8f924bf129d9364468c2cfa8c250d. Trace how the global plugin mapping is applied to scenes; done means the mapped plugin is available as scene.test in HEADLESS mode, with the relevant regression covered by a test or reproducible example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100