From 9b408bb063190431f243827b5deff077d88ed044 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Thu, 23 Mar 2017 08:16:22 +0100 Subject: [PATCH] Reorganized code: created Entity base class modified: shapeshift.js --- shapeshift.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/shapeshift.js b/shapeshift.js index 37481aa..14b4fda 100644 --- a/shapeshift.js +++ b/shapeshift.js @@ -63,15 +63,12 @@ } }, false); - class Player extends Phaser.Sprite { + class Entity extends Phaser.Sprite { constructor(x, y, sprite) { super(game, x, y, sprite); - this.anchor.setTo(.4,.5); + this.anchor.setTo(.5,.5); this.scale.x = 0.5; this.scale.y = this.scale.x; - this.pushed = 0; - this.shape = SHAPE_GIRL; - this.learnedBird = false; } enablePhysics() { @@ -83,24 +80,23 @@ } } - class Guard extends Phaser.Sprite { + class Player extends Entity { + constructor(x, y, sprite) { + super(x, y, sprite); + this.anchor.setTo(.4,.5); + this.pushed = 0; + this.shape = SHAPE_GIRL; + this.learnedBird = false; + } + } + + class Guard extends Entity { constructor(x, y, sprite, dialogues) { //var guard = game.add.sprite(x, y, sprite); - super(game, x, y, sprite); - this.anchor.setTo(.5,.5); - this.scale.x = 0.5; - this.scale.y = this.scale.x; + super(x, y, sprite); this.dialogues = dialogues; guards.add(this); } - - enablePhysics() { - game.physics.arcade.enable(this); - this.body.bounce.y = 0.2; - this.body.bounce.x = 0.2; - this.body.gravity.y = 300; - this.body.collideWorldBounds = true; - } } function sign(n) { -- 2.34.1