TypeScript will transpile this code with no problems:
let sprite:Phaser.Physics.Matter.Sprite = this.matter.add.sprite(200, 50, 'image'); let speed:number = MatterJS.Vector.magnitude(sprite.body.velocity); console.log(speed);
But when run it I get this error:
Uncaught ReferenceError: MatterJS is not defined
Is this a configuration issue on my end? Something to do with how Phaser integrates with Matter?
This is just one example of the problem, I had the exact same issue when trying to use MatterJS.Vertices.centre… So I imagine the problem is going to keep coming up.
I have some really vague notions of what could be going on, but I don’t understand enough about how all these technologies work to figure out more than that right now. Would appreciate some advice… Maybe this TypeScript code snipped works fine for others and I have just configured my project incorrectly. I’m using VSCode and webpack. Thank you!