Hi everyone, I was hoping I might be able to get some help with creating a map class.
This is what I have so far
class Map {
constructor (scene)
{
scene.map = scene.make.tilemap({
key: 'map'
});
let tiles = scene.map.addTilesetImage('spritesheet', 'tiles');
scene.map.createStaticLayer('Grass', tiles, 0, 0);
scene.obstacles = scene.map.createStaticLayer('Obstacles', tiles, 0, 0);
scene.interactives = scene.map.createStaticLayer('Interactive', tiles, 0, 0);
scene.obstacles.setCollisionByExclusion([-1]);
scene.interactives.setCollisionByExclusion([-1]);
scene.physics.world.bounds.width = scene.map.widthInPixels;
scene.physics.world.bounds.height = scene.map.heightInPixels;
}
}
I would like to create this from an existing class in Phaser. I am thinking the extension I need is Phaser.Tilemaps.Tilemap, but whenever I tried to make it that way I can’t seem to get anything to work.
Example
class Map extends Phaser.Tilemaps.Tilemap
{
constructor (scene, key)
{
super(scene, key);
}
}
let map = new Map(this, {key: 'map'});
Help?