zlegacy

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. Hey all, I have a rather large codebase that I was hoping to convert to take advantage of Phaser and running into an issue that I am fairly clueless on. I have loaded a sprite sheet and am trying to add the sprite to a player object but am getting this error: Uncaught TypeError: Cannot read property 'sprite' of undefined. playerObject.prototype.createPlayer = function() { if (this.isDead == false) { // x, y, name let player_x = Array.isArray(room.map.json.player) ? room.map.json.player[0] : 0 let player_y = Array.isArray(room.map.json.player) ? room.map.json.player[1] : 0 this.physic = new physicsBody({ type: "dynamic" , shape: "circle" , x: player_x / physics.scale , y: player_y / physics.scale , radius: 0.5 , fixedRotation: true , mass: 20 , userData: this }) this.anim = mainGame.add.sprite(player_x, player_y, 'run') } This is a multiplayer game, so I create all my players and am trying to assign this specific sprite. I can console.log mainGame and get the proper information, so I know that's not undefined. I'm not getting any other errors, so I'm really not sure what the problem is here.