Hello, I am new to phaser. I want to set a body to change a dynamic body to a static body if certain conditions are met. I created a simple example to try to get it working but without luck:
class NormScene extends Phaser.Scene {
constructor(config) {
super({ key: ‘NormScene’ })
this.config=config;
this.ball = null;
}preload()
{}create() {
let circle = this.add.circle(200,110,50, 0x00FF00 ); let body = this.matter.add.circle(200,110,50,{ isStatic: false, }) ; this.ball = this.matter.add.gameObject(circle,body); } update(time, delta) { if(time>1000){ this.matter.body.setStatic(this.ball, true); } }
}
the error I get is:
Uncaught TypeError: Cannot read properties of undefined (reading ‘length’)
at Object.Body.setStatic (phaser.js:10815:40)
at NormScene.update (NormScene.js:23:30)
at Systems.step (phaser.js:49068:26)
at SceneManager.update (phaser.js:100289:21)
at Game.step (phaser.js:162805:20)
at TimeStep.step (phaser.js:89366:14)
at step (phaser.js:89613:19)