Update server/static/map.js
This commit is contained in:
@@ -10,7 +10,7 @@ export class MapView {
|
||||
this.target = null;
|
||||
this.nodes = [];
|
||||
this.nodeSprites = new Map();
|
||||
this.otherSprites = new Map(); // id -> { img,label }
|
||||
this.otherSprites = new Map(); // socket.id -> { img,label }
|
||||
}
|
||||
|
||||
create(me, world, nodes) {
|
||||
@@ -22,22 +22,21 @@ export class MapView {
|
||||
// background
|
||||
this.scene.add.rectangle(W / 2, H / 2, W, H, 0x020617).setDepth(-100);
|
||||
|
||||
// player
|
||||
// player sprite
|
||||
this.player = this.scene.add.image(me.x, me.y, 'player').setDepth(10);
|
||||
this.nameText = this.scene
|
||||
.add.text(me.x, me.y - 22, me.name || 'You', {
|
||||
.add.text(me.x, me.y - 22, me.username || me.name || 'You', {
|
||||
fontSize: '12px',
|
||||
color: '#e5e7eb'
|
||||
})
|
||||
.setOrigin(0.5);
|
||||
|
||||
// camera
|
||||
// camera follow
|
||||
const cam = this.scene.cameras.main;
|
||||
cam.setBounds(0, 0, W, H);
|
||||
cam.startFollow(this.player, true, 0.15, 0.15);
|
||||
cam.setZoom(this.config.zoom);
|
||||
|
||||
// nodes
|
||||
this.replaceNodes(nodes || []);
|
||||
}
|
||||
|
||||
@@ -51,7 +50,6 @@ export class MapView {
|
||||
}
|
||||
|
||||
replaceNodes(list) {
|
||||
// remove existing
|
||||
for (const sprite of this.nodeSprites.values()) {
|
||||
sprite.destroy();
|
||||
}
|
||||
@@ -120,7 +118,6 @@ export class MapView {
|
||||
rec.label.setPosition(p.x, p.y - 22);
|
||||
}
|
||||
}
|
||||
// remove missing
|
||||
for (const [id, rec] of this.otherSprites) {
|
||||
if (!seen.has(id)) {
|
||||
rec.img.destroy();
|
||||
|
||||
Reference in New Issue
Block a user