weo_af

Members
  • Content Count

    4
  • Joined

  • Last visited

About weo_af

  • Rank
    Newbie

Profile Information

  • Gender
    Not Telling
  1. This is very helpful! I'm definitely going to check out this tutorial more and decide the best way for my needs! I really appreciate the help!
  2. Is there additional benefits to having it all in one state? I'm not disagreeing but I'm just curious. I really appreciate the advice. Also would you create a level data object for each level and then when you reach the end of a level just load levelData2 (for example) into the state?
  3. Okay I've been trying to work this out on my own and this is what I have so far. In my MainMenu State I have: BasicGame.Player = function (game) {};BasicGame.Player.prototype = { create: function (game, x, y) { this.test = "new player created"; console.log(game); this.jumpSound = game.add.audio('jump'); this.player = game.add.sprite(x, y, 'player'); game.physics.arcade.enable(this.player); this.player.body.collideWorldBounds = true; this.player.body.gravity.y = 1000; this.player.animations.add('left', [1, 2, 3, 4, 5, 6, 7, 8], 10, true); this.player.animations.add('right', [9, 10, 11, 12, 13, 14, 15, 16], 10, true); this.player.frame = 17; return this.player; }, update: function (cursors) { this.player.body.velocity.x = 0; this.player.body.velocity.x = 0; console.log(this.game); if(cursors.left.isDown) { this.player.body.velocity.x = -150; this.player.animations.play('left'); this.direction = 'left'; } else if(cursors.right.isDown) { this.player.body.velocity.x = 150; this.player.animations.play('right'); this.direction = 'right'; } else if(cursors.down.isDown && this.player.body.onFloor()) { if(this.direction === 'left') { this.player.frame = 18; } else if(this.direction === 'right') { this.player.frame = 19; } } else { this.player.animations.stop(); if(this.direction === 'left') { this.player.frame = 0; } else if(this.direction === 'right') { this.player.frame = 17; } } if(cursors.up.isDown && this.player.body.onFloor()) { if(!this.jumpSound.isPlaying){ this.jumpSound.play(); } this.player.body.velocity.y = -400; } }}And then in my Game state creat function I have this.player = BasicGame.Player.prototype.create(this.game, 20, 150);And in the update function I have BasicGame.Player.prototype.update(this.cursors);It's working pretty well but I'd definitely be interested in knowing if there is a better way to achieve this.
  4. I am very much new to Phaser and Game Development in general and I had a quick questions about player controls through multiple states. I recently made a small "game" that had a player walking through different levels that I created using different states. But I just copied and pasted the code for movement in the update function for each different state. I assume there is a better way to do this, maybe in a separate function somewhere, but where? Any help would be greatly appreciated.