Hi all,
I’m following the tutorial to create an endless runner but I’m trying to do it in typescript and I’m getting a frustrating error. When running this code:
const platform = this.add
.tileSprite(posX, 0, platformWidth, 32, "platform")
.setOrigin(0.5, 0)
.setY(this.nextPlatformY);
this.platforms?.add(platform);
this.physics.add.existing(platform);
platform.body?.setImmovable(true);
platform.body?.setFriction(0);
platform.body?.setVelocityX(this.speed * -1);
I get the following typescript error:
Property 'setImmovable' does not exist on type 'Body | StaticBody | BodyType'.
Property 'setImmovable' does not exist on type 'StaticBody'.
I understand what the error means but I’m hoping someone can tell me how to access those physics related methods in a typesafe way once the tileSprite has been added to the scene.