Skip to content

Phaser.Physics.Matter.Image, Phaser.Physics.Matter.Sprite: setToSleep and setAwake functions should return this #5567

@micsun-al

Description

@micsun-al

Version

  • Phaser Version: 3.52.0
  • Operating system: macOs Catalina 10.15.7
  • Browser: n/a

Description

Phaser.Physics.Matter.Image and Phaser.Physics.Matter.Sprite's setToSleep and setAwake functions should return this.
https://github.com/photonstorm/phaser/blob/v3.52.0/src/physics/matter-js/components/Sleep.js#L19
(Maybe just add return this as the last lines in each function?)
Not having this breaks people chaining calls.

Example Test Code

this.image = scene.matter.add.image(0, 0, `main`, `game/ball`)
  .setToSleep() // Bug - doesn't return the instance

console.log(`GameBall.js: this.image:`, this.image) // undefined

Additional Information

Yay.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions