{"size": 1074, "ext": "js", "max_stars_repo_path": "www/app/views/helpee_sprite_view.js", "max_stars_repo_name": "JayChetty/primegamemobile", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "www/app/views/helpee_sprite_view.js", "max_issues_repo_name": "JayChetty/primegamemobile", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "www/app/views/helpee_sprite_view.js", "max_forks_repo_name": "JayChetty/primegamemobile", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.347826087, "max_line_length": 71, "alphanum_fraction": 0.6703910615}
var HelpeeSpriteView = function(spec){
  var spec = spec || {}

    
  this.leftWalk = PIXI.Texture.fromImage("asset/dog.png");
  this.rightWalk = PIXI.Texture.fromImage("asset/dog.png");
  this.walkTextures = [];
  this.walkTextures.push(this.leftWalk);
  this.walkTextures.push(this.rightWalk);
  this.phase = 0;
    
  this.model = spec.model;
  this.sprite = spec.sprite;
  this.sprite.setTexture(this.leftWalk)
  this.syncPosition();

  this.model.on('change',function(){
    this.syncPosition();
  },this)

  //clicks change position
  this.sprite.interactive = true;

}


HelpeeSpriteView.prototype = {
  
  updatePosition:function(){
    this.phase++
    this.model.moveInDirection();
    if(this.model.target && this.phase%10===0){     
      this.sprite.setTexture(this.walkTextures[this.phase%20/10]);     
    }   
  },
  

  syncPosition:function(){
    this.sprite.position.x = this.model.position.x;
    this.sprite.position.y = this.model.position.y;
    this.sprite.rotation = (Math.PI/2) - (this.model.direction);
  },

}

module.exports = HelpeeSpriteView