Skip to content

game.add.spriteBatch parameters suggestion #1000

@petarov

Description

@petarov

From the SpriteBatch docs:

new SpriteBatch(game, parent, name, addToStage)
parent - ... If undefined or null it will use game.world.

This is a simple suggestion that allows for the parent parameter to be skipped, therefore adding the SpriteBatch directly to game.world.

In GameObjectFactory

    spriteBatch: function (parent, name, addToStage) {
        if (typeof parent === 'string') {
            addToStage = typeof name === 'boolean' ? name : addToStage;
            name = parent;
            parent = undefined;
        }
        if (typeof name === 'undefined') { name = 'group'; }
        if (typeof addToStage === 'undefined') { addToStage = false; }

        return new Phaser.SpriteBatch(this.game, parent, name, addToStage);

    },

e.g.,

this.game.add.spriteBatch('batch');
this.game.add.spriteBatch('batch', false);

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