marzipanlabs

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. I got it working. I added: BasicGame.player = new BasicGame.Player(game)To the javascript section in index.html right below the line where I created the game var. It didn't work right away. When I called BasicGame.player.create() in the create function of my level prototype, it didn't work. When I changed the player function name to add() and called BasicGame.player.add() it worked. On the other hand I was able to call BasicGame.player.update() in the update function of my level prototype, and that worked fine.
  2. Oops, I meant to post to another thread. I'm not sure how to delete my post now. This was a good thread though and helped me understand working with javascript objects w/r/t Phaser state management.
  3. This sounded so simple the first time I read it, but unfortunately I'm having trouble with it. I have a player class that looks something like Rich's example below, as well as various states corresponding to different parts of my game -- boot, preloader, level1, level2, etc . But what I'm unsure about is where to "create the player object when the game starts" and then how to "add a reference to the object" in each level. Do I create the player in my index.html where I create the main game variable? Or do I create it in Boot.js where I have some other global variables as part of the BasicGame object, like "score" for example? I assume I need to do something like: var player = new BasicGame.Player(game) at some point, but I'm not sure where and I haven't figured it out by experimentation yet. I would appreciate any help.