misc phaser
This commit is contained in:
parent
dadc6e4a9e
commit
72886c262e
@ -5,7 +5,7 @@ class PhaserCombat extends Phaser.Scene {
|
|||||||
/* Static Images */
|
/* Static Images */
|
||||||
this.load.image('sky', 'http://labs.phaser.io/assets/skies/nebula.jpg');
|
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('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('alk', 'https://i.imgur.com/RFP8Pfz.png');
|
||||||
this.load.image('magmar', 'https://i.imgur.com/CBNokzR.png');
|
this.load.image('magmar', 'https://i.imgur.com/CBNokzR.png');
|
||||||
/* Spritesheets */
|
/* Spritesheets */
|
||||||
@ -35,17 +35,15 @@ class PhaserCombat extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createProj() {
|
createProj() {
|
||||||
|
this.combat = true;
|
||||||
this.proj = this.physics.add.image(-100, 300, 'proj');
|
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({
|
this.emitter = particles.createEmitter({
|
||||||
speed: 100,
|
speed: 25,
|
||||||
scale: { start: 1, end: 0 },
|
scale: { start: 1, end: 0 },
|
||||||
blendMode: 'ADD',
|
blendMode: 'ADD',
|
||||||
});
|
});
|
||||||
this.emitter.startFollow(this.proj);
|
this.emitter.startFollow(this.proj);
|
||||||
}
|
|
||||||
|
|
||||||
createColliders() {
|
|
||||||
this.physics.add.overlap(this.proj, this.players, this.explode, null, this);
|
this.physics.add.overlap(this.proj, this.players, this.explode, null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,21 +67,17 @@ class PhaserCombat extends Phaser.Scene {
|
|||||||
|
|
||||||
shootRight() {
|
shootRight() {
|
||||||
if (!this.combat) {
|
if (!this.combat) {
|
||||||
this.combat = true;
|
|
||||||
this.createProj();
|
this.createProj();
|
||||||
this.createColliders();
|
|
||||||
this.proj.x = 180;
|
this.proj.x = 180;
|
||||||
this.proj.setVelocity(150, 0);
|
this.proj.setVelocity(250, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shootLeft() {
|
shootLeft() {
|
||||||
if (!this.combat) {
|
if (!this.combat) {
|
||||||
this.combat = true;
|
|
||||||
this.createProj();
|
this.createProj();
|
||||||
this.createColliders();
|
this.proj.x = 400;
|
||||||
this.proj.x = 450;
|
this.proj.setVelocity(-250, 0);
|
||||||
this.proj.setVelocity(-150, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class PhaserInstance extends preact.Component {
|
|||||||
// now mounted, can freely modify the DOM:
|
// now mounted, can freely modify the DOM:
|
||||||
this.PhaserCombat = new PhaserCombat();
|
this.PhaserCombat = new PhaserCombat();
|
||||||
const config = {
|
const config = {
|
||||||
type: Phaser.AUTO,
|
type: Phaser.DOM.FILL,
|
||||||
width: 600,
|
width: 600,
|
||||||
height: 400,
|
height: 400,
|
||||||
parent: 'phaser-example',
|
parent: 'phaser-example',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user