Skip to content

Global plugins not mapped on scene when render type is Phaser.HEADLESS #7348

Description

@TJ09

Version

  • Phaser Version: 3.88-3.90
  • Operating system: Windows/Linux (Not specific to any)
  • Browser: Tested in Firefox/Chrome

Description

As of 8736f0e, 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
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions