import Phaser from 'phaser'

export default class extends Phaser.Sprite {

    constructor ({ game, asset }) {
        super(game, 0, 0, asset)
        this.texture.baseTexture.scaleMode = PIXI.scaleModes.NEAREST;
        this.game = game
        this.anchor.setTo(0.5)
        this.checkWorldBounds = true;
        this.outOfBoundsKill = true;
        this.exists = false;
        this.tracking = false;
        this.scaleSpeed = 0;
    }

    fire(x, y, angle, speed, _gx, _gy) {
        let gx = _gx || 0;
        let gy = _gy || 0;

        this.reset(x, y);
        this.scale.set(0.5);
        this.game.physics.arcade.velocityFromAngle(angle, speed, this.body.velocity);
        this.angle = angle;
        this.body.gravity.set(gx, gy);
    }

    update () {
        if (this.game.pseudoPause) {
          if(!this.prevVel){
            this.prevVel = this.body.velocity;
            this.body.velocity = 0;
          }
            return;
        }else{
          if(this.prevVel){
            this.body.velocity = this.prevVel;
            this.prevVel = null;
          }
        }

    }


}

@@ -904,16 +904,56 @@
 velocity
+.x = 0;%0A            this.body.velocity.y
  = 0;%0A  
@@ -1055,16 +1055,18 @@
 velocity
+.x
  = this.
@@ -1072,16 +1072,69 @@
 .prevVel
+.x;%0A            this.body.velocity.y = this.prevVel.y
 ;%0A      

take 2