Jump to content

Issue making player class


shmellyorc
 Share

Recommended Posts

Hello, I am trying to make an entity class which holds the textures, player data, etc. I keep getting "Uncaught TypeError: undefined is not a function" in chrome which I am not sure how to fix it. Works perfectly in VS2013. This is a typescript project.

 

GameState.Ts:

module TinyRpg.State {  export class GameState extends Phaser.State {    public _player: TinyRpg.Entity;      constructor() {        super();      }		      preload() {	this._player = new TinyRpg.Entity(this.game, EntityType.Player, 0);      }      render() {	this._player.draw();      }   }} 

Entities.Ts:

enum EntityType {  Player,  Enemy,  Npc,}module TinyRpg  {  export class Entity extends Phaser.Sprite {    public name: string="";    public minHealth: number = 0;    public maxHealth: number = 0;    public minXp: number = 0;    public maxXp: number = 0;    public strength: number = 0;    public defense: number = 0;    public evade: number = 0;    public luck: number = 0;		    public unitID: number = 0;    public  _id: string;    public game: Phaser.Game;    constructor(game: Phaser.Game, entityType: EntityType, unitID: number) {      super(game, 0, 0, '');      this.game = game;      this.unitID = unitID;				      if (entityType == EntityType.Player)	this.key = 'player';      else if (entityType == EntityType.Enemy)	this.key = 'enemy';      else if (entityType == EntityType.Npc)	this.key = 'npc';		    }    draw() {      this.game.add.image(0, 0, this.key);    }  }} 
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...