class Map extends Phaser.Tilemaps.Tilemap {
constructor (scene, mapData)
{
super(scene, mapData);
this._widthInPixels = this.widthInPixels;
this._heightInPixels = this.heightInPixels
console.log(this._widthInPixels); //THIS IS WHERE THE PROBLEM IS :: RETURNS undefined
scene.physics.world.bounds.width = this._widthInPixels;
scene.physics.world.bounds.height = this._heightInPixels;
}
get widthInPixels()
{
return this._widthInPixels;
}
get heightInPixels()
{
return this._heightInPixels;
}
}
Everything works in the above code except I can’t get widthInPixels. The map renders perfectly and physics work and everything is great–except, I can’t get the value of widthInPixels so I can apply world bounds to the map bounds.
I’m not sure why, it’s not working–I’ve checked the documentation, and ‘widthInPixels’ IS in the Tilemap class that I am extending. I’ve provided the mapdata which it is obviously received and working well with since it’s rendering the map. I just don’t understand why this isn’t working. What am I missing?