From 72886c262ee5ac21ce669e03bf77ae5ea21f5425 Mon Sep 17 00:00:00 2001 From: Mashy Date: Wed, 31 Oct 2018 12:41:34 +1000 Subject: [PATCH] misc phaser --- client/src/components/phaser.combat.js | 20 +++++++------------- client/src/components/phaser.container.jsx | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/client/src/components/phaser.combat.js b/client/src/components/phaser.combat.js index a953d70f..bee93ba8 100755 --- a/client/src/components/phaser.combat.js +++ b/client/src/components/phaser.combat.js @@ -5,7 +5,7 @@ class PhaserCombat extends Phaser.Scene { /* Static Images */ this.load.image('sky', 'http://labs.phaser.io/assets/skies/nebula.jpg'); this.load.image('proj', 'http://labs.phaser.io/assets/sprites/bullet.png'); - this.load.image('red', 'http://labs.phaser.io/assets/particles/red.png'); + this.load.image('blue', 'http://labs.phaser.io/assets/particles/blue.png'); this.load.image('alk', 'https://i.imgur.com/RFP8Pfz.png'); this.load.image('magmar', 'https://i.imgur.com/CBNokzR.png'); /* Spritesheets */ @@ -35,17 +35,15 @@ class PhaserCombat extends Phaser.Scene { } createProj() { + this.combat = true; this.proj = this.physics.add.image(-100, 300, 'proj'); - const particles = this.add.particles('red'); + const particles = this.add.particles('blue'); this.emitter = particles.createEmitter({ - speed: 100, + speed: 25, scale: { start: 1, end: 0 }, blendMode: 'ADD', }); this.emitter.startFollow(this.proj); - } - - createColliders() { this.physics.add.overlap(this.proj, this.players, this.explode, null, this); } @@ -69,21 +67,17 @@ class PhaserCombat extends Phaser.Scene { shootRight() { if (!this.combat) { - this.combat = true; this.createProj(); - this.createColliders(); this.proj.x = 180; - this.proj.setVelocity(150, 0); + this.proj.setVelocity(250, 0); } } shootLeft() { if (!this.combat) { - this.combat = true; this.createProj(); - this.createColliders(); - this.proj.x = 450; - this.proj.setVelocity(-150, 0); + this.proj.x = 400; + this.proj.setVelocity(-250, 0); } } diff --git a/client/src/components/phaser.container.jsx b/client/src/components/phaser.container.jsx index fa7bdb86..29946187 100755 --- a/client/src/components/phaser.container.jsx +++ b/client/src/components/phaser.container.jsx @@ -35,7 +35,7 @@ class PhaserInstance extends preact.Component { // now mounted, can freely modify the DOM: this.PhaserCombat = new PhaserCombat(); const config = { - type: Phaser.AUTO, + type: Phaser.DOM.FILL, width: 600, height: 400, parent: 'phaser-example',