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

Exception in Arcade Static Body.setGameObject method, null pointer #6969

Open
yongzheng7 opened this issue Nov 27, 2024 · 3 comments
Open

Exception in Arcade Static Body.setGameObject method, null pointer #6969

yongzheng7 opened this issue Nov 27, 2024 · 3 comments

Comments

@yongzheng7
Copy link

Version

  • Phaser Version:
    Phaser Version: 3.86.0
  • Browser:

Description

The newly created Static Body has a null pointer exception when setting setGameObject
image

@samme
Copy link
Contributor

samme commented Nov 27, 2024

I guess setGameObject() could handle this better, but if you're creating the body yourself you should just pass gameObject in new StaticBody().

@photonstorm
Copy link
Collaborator

What code did you use to create this? We really need to see sample code to know if this is a bug, or just an implementation issue, thanks.

@yongzheng7
Copy link
Author

你用什么代码来创建这个?我们真的需要查看示例代码才能知道这是一个错误,还是只是一个实现问题,谢谢。

const staticBody = this.physics.add.staticBody(0, 0, 10, 10)
const rect = this.add.rectangle(0, 0, 10, 10)
staticBody.setGameObject(rect)

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

No branches or pull requests

3 participants