Jopidia

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. This thread might come across as a little different... Phaser has a lot of great tools and functions that I can use in my games, but I'm having trouble learning exactly what these functions do and how to utilize them. So far, I've been checking the API Documentation and Phaser Search Docs, but I have trouble finding functions that solve my specific problem at the time. I'm not really interested in going through a bunch of tutorials, because I don't believe them to be an effective method of learning how to make games. For reference, they're fine. I'm just curious as to what other people do to look for tools/help. I'm very inexperienced to Phaser AND making games in general, so any help (resources, tips, etc.) would be greatly appreciated! Here's a good example issue: Right now, I'm making a simple overhead game where my sprite can move using WASD. Everything is working fine and dandy - however, when the sprite moves diagonally (up and right at the same time), it moves faster (more pixels per second) than it does when moving straight up, down, left, or right (code shown below). What resources would you look through to find tools to solve a problem like that? Or would the best way be to change the x and y velocity when two directions are pushed at once so that the diagonal speed is equal to the max velocity (in other words, use math)? Please excuse my noobism. create: function() { // Prepares keyboard for input keyboard = this.game.input.keyboard; player1 = this.game.add.sprite(16, 16, "player1"); game.physics.enable(player1, Phaser.Physics.ARCADE); player1.body.collideWorldBounds = true; }, update: function() { // Sprite can move (W, A, S, D) if (keyboard.isDown(Phaser.Keyboard.A)) { player1.body.velocity.x = -175; } else if (keyboard.isDown(Phaser.Keyboard.D)) { player1.body.velocity.x = 175; } else { player1.body.velocity.x = 0; } if (keyboard.isDown(Phaser.Keyboard.W)) { player1.body.velocity.y = -175; } else if (keyboard.isDown(Phaser.Keyboard.S)) { player1.body.velocity.y = 175; } else { player1.body.velocity.y = 0; } },