Skip to content

Preserve physics group config with existing children#7322

Open
Farley-Chen wants to merge 1 commit into
phaserjs:masterfrom
Farley-Chen:fix-physics-group-config
Open

Preserve physics group config with existing children#7322
Farley-Chen wants to merge 1 commit into
phaserjs:masterfrom
Farley-Chen:fix-physics-group-config

Conversation

@Farley-Chen

Copy link
Copy Markdown

Summary

Preserve the provided config when creating Arcade Physics groups with existing children.

Both dynamic and static physics groups replaced the provided config when children was not a plain object or an array of plain objects. This caused options passed as the second argument to be ignored for calls like:

this.physics.add.group([sprite], {
    collideWorldBounds: true
});

this.physics.add.staticGroup([platform], config);

This change keeps the existing config object and appends the internal callbacks instead of replacing it.

Manual test

Created an Arcade Physics Group from an existing GameObject array with { collideWorldBounds: true }.

Before this change:

group.defaults.setCollideWorldBounds === false
sprite.body.collideWorldBounds === false

After this change:

group.defaults.setCollideWorldBounds === true
sprite.body.collideWorldBounds === true

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

Successfully merging this pull request may close these issues.

1 participant