remove background, scroll zoom compensation
This commit is contained in:
parent
e3277c3478
commit
e304f801d5
@ -10,7 +10,6 @@ const passiveDataEdge = require('./passive.data.edge');
|
||||
class PhaserPassives extends Phaser.Scene {
|
||||
preload() {
|
||||
this.load.image('eye', 'https://labs.phaser.io/assets/particles/green-orb.png');
|
||||
this.load.image('background', 'http://labs.phaser.io/assets/skies/nebula.jpg');
|
||||
}
|
||||
|
||||
create() {
|
||||
@ -22,9 +21,6 @@ class PhaserPassives extends Phaser.Scene {
|
||||
}
|
||||
|
||||
init() {
|
||||
this.background = this.add.image(0, 0, 'background');
|
||||
this.background.setScale(5);
|
||||
this.background.setInteractive();
|
||||
this.graphics = this.add.graphics();
|
||||
this.textGraphic = new Phaser.GameObjects.Graphics(this);
|
||||
this.add.existing(this.textGraphic);
|
||||
@ -59,13 +55,12 @@ class PhaserPassives extends Phaser.Scene {
|
||||
gameObjects[0].setTint(0xff00ff);
|
||||
}
|
||||
this.displayPassiveText(gameObjects[0], pointer);
|
||||
} else if (this.nodeText) {
|
||||
this.nodeText.destroy();
|
||||
}
|
||||
});
|
||||
this.input.on('pointerout', (pointer, gameObjects) => {
|
||||
if (gameObjects[0] instanceof PassiveNode) {
|
||||
if (!gameObjects[0].alloc) gameObjects[0].clearTint();
|
||||
this.nodeText.destroy();
|
||||
}
|
||||
});
|
||||
this.input.on('pointerup', (pointer, gameObjects) => {
|
||||
@ -79,10 +74,11 @@ class PhaserPassives extends Phaser.Scene {
|
||||
}
|
||||
});
|
||||
this.input.on('pointermove', (pointer) => {
|
||||
const zoomFactor = 2 / this.cameras.main.zoom;
|
||||
if (this.pan) {
|
||||
const points = pointer.getInterpolatedPosition(2);
|
||||
this.cameras.main.scrollX -= (points[1].x - points[0].x) * 2;
|
||||
this.cameras.main.scrollY -= (points[1].y - points[0].y) * 2;
|
||||
this.cameras.main.scrollX -= zoomFactor * (points[1].x - points[0].x);
|
||||
this.cameras.main.scrollY -= zoomFactor * (points[1].y - points[0].y);
|
||||
}
|
||||
}, this);
|
||||
this.input.keyboard.on('keydown_A', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user