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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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