Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resetting a static body should reapply the offset #6729

Closed
samme opened this issue Feb 2, 2024 · 1 comment · Fixed by #6730
Closed

Resetting a static body should reapply the offset #6729

samme opened this issue Feb 2, 2024 · 1 comment · Fixed by #6730

Comments

@samme
Copy link
Contributor

samme commented Feb 2, 2024

Version

  • Phaser Version: 3.70.0 and earlier

Description

Create a game object with a static Arcade Physics body. Give the body an offset with setOffset(x, y).

Reset the body with any coordinates. Now the body position doesn't include the offset.

Call setOffset(x, y) again. The body position is the same — still no offset.

Example Test Code

const image = this.physics.add.staticImage(0, 0, '32x32').setOffset(16, 16);

// These pass.
console.assert(image1.body.x === 0);
console.assert(image1.body.y === 0);

// Reset on the original position.
image.body.reset(0, 0);

// These fail.
console.assert(image1.body.x === 0);
console.assert(image1.body.y === 0);

Also https://codepen.io/samme/pen/wvOjoGK?editors=0010

@rgk
Copy link
Contributor

rgk commented Feb 2, 2024

✌️

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 a pull request may close this issue.

2 participants