Jump to content

PixelProgrammer

Members
  • Content Count

    29
  • Joined

  • Last visited

Everything posted by PixelProgrammer

  1. Hey there, So I've snagged onto a little problem while developing my game. I'm using Phaser with it's inbuilt support of gamepad. The axis of the controller input works in a way such that it returns 1 when held to the right and -1 when held to the left. Here's a picture to make things easier to understand. How would I map the values to degrees? Here's a visual representation of what I'd like to get. What's a formula that would allow me to do this?
  2. @samme you beautiful human being! orb.world was just what I wanted. Thank you!
  3. Hi there! So here's my issue. I have a player sprite which has an orb sprite attached to it as a child. Player = function (game, x, y, image) { Phaser.Sprite.call(this, game, x, y, image); //calls constructor this.orb = this.addChild(game.make.sprite(0, 0, 'orb')); game.add.existing(this); }; /*--------------------------------------------------------*/ Player.prototype = Object.create(Phaser.Sprite.prototype); Player.prototype.constructor = Player; /*--------------------------------------------------------*/ I want to reference the x and y positions of the orb
  4. @samme Thank you. However, I'm afraid I won't be able to use the CE since I've already built most of my game on the official version. Do you think there's another way I could fire multiple bullets at the same time?
  5. @samme I saw that on another thread but was unsure of what it was. Could you please explain or give me a list of what Phaser CE is and how I'd implement it?
  6. Hi there, I want to build a shotgun weapon for my game. This shotgun would shoot 3 (or more) bullets in a conical angle. However, from what I see, Phaser.Weapon only fires one bullet at a time. What do I do in order to get the weapon to fire 3 bullets consecutively
  7. Hi there, I want to extend Phaser.Weapon so I can create my own custom weapons. I know that you extend groups by using Weapon.SingleBullet = function (game) { Phaser.Group.call(this, game, game.world, 'Single Bullet', false, true, Phaser.Physics.ARCADE); return this; }; Weapon.SingleBullet.prototype = Object.create(Phaser.Group.prototype); Weapon.SingleBullet.prototype.constructor = Weapon.SingleBullet; But what about the weapons group? Are there any examples out there for this? EDIT: I used Weapon.SingleBullet.prototype = Object.create(Phaser.W
  8. So I'm currently following @rich 's Shoot-em-up tutorial from over here https://phaser.io/tutorials/coding-tips-007. Please have a look at the source code if you haven't already. From what I understand he create's a weapon array that holds all the weapon types (each of which are an object inside a Weapon object). Now my question is How do I access the current weapon bullets in game.physics.arcade.collide? I've used game.physics.arcade.collide(this.weapon[this.currentWeapon], this.enemies) and this works fine, the bullets and the enemy collide well. BUT what if I wan
  9. @drhayes I'm sorry if I phrased the question badly. Let me clarify. I want to use phasers call back function. When I click the button I want the function to run. BUT I ALSO want to run the function whenever I want (For example when the user presses A on the controller). Now I know I can put all the callback functions in an array (and this is what I'm currently doing). But I feel this is bad code. Because if I were to rearrange buttons, I would have to rearrange the callback functions in the code in the same order as the buttons. I was just wondering if there was a
  10. So I'm currently trying to implement controller support in my menu. The way I'm doing this right now is by pushing all the buttons into an array and when the player presses up or down on the dpad, they traverse through the array. But here's the issue. What do I use to access the callback parameter of the button? Essentially what I want to do is when the player reaches the button he wants to press in the array, I want to run the callback function. I know phaser does the automatically if you clicked the button. But what if I want to do it manually? if (contro
  11. @mwiss Thanks I've implemented something like what you've recommended.. movePlayer: function (player) { if (!player.alive) return ; var pad = (player.color == "red") ? this.pad1 : this.pad2; /*-- Movements --*/ if (player.cursor.left.isDown || pad.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_X)< -0.1){ //move left player.body.velocity.x = -300; player.animations.play('left'); } else if (player.cursor.right.isDown || pad.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_X)>0.1){ //move right player.body
  12. I'm currently building a two player platform-shooting game that supports controllers. Right now I have two separate move functions placed in the update that handles player movement. Here's the code: movePlayer1: function () { if (!player.alive) return ; //controller input if(this.pad1.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_X)< -0.1){ this.player_1.body.velocity.x = -300; //move left this.player_1.animations.play('left'); } if(this.pad1.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_X)>0.1){ this.player_1.body.velocity.x = 300; //move
  13. @Legomite Theoretically it should cost less since it wouldn't have to render it.
  14. @aarroyoc said it best. You need a simple HTTP server. I'd suggest Mongoose which is a lightweight server. If you're using Webstorm as an IDE you can use the inbuilt server.
  15. Currently, in my game. I've done the following if (player.fireButton.isDown) { //firing straight up player.weapon.fireAngle = Phaser.ANGLE_UP; player.weapon.fire(); this.shootSfx.play(); } The issue with this is that when I hold down the `fireButton` the first millisecond of the sound is played on a loop. Basically, the sound just keeps resetting. How do I set it up so that it has to play the full sound clip before starting again? Also, are there any Phaser examples of sounds and weapons being used together?
  16. Awesome, this seems to work with some slight modifications. I had previously set world gravity to 1000. All i had to do was weapon.bulletGravity.y = -1000;
  17. @PhasedEvolution Yes, I could apply gravity to a sprite body. However, i'm using the Phaser.Weapon class. And if I try `weapon.body.gravity.y = 0;` I just get an error saying "Cannot read property 'gravity' of undefined". Same thing for weapon.bullets
  18. Hi there, I'm creating a simple platform game where you can shoot enemies. I've applied game.physics.arcade.gravity.y = 1000; But this seems to now affect my weapon class and bullets too! How do I set my weapons or bullets to NOT be affected by gravity? Here's the code I've used for reference: var playState = { //code to make assets goes here create: function(){ /*-- creating player --*/ game.add.sprite(0, 0, 'background'); game.physics.arcade.gravity.y = 1000; //Do not enable, need to fix gravity. this.player = game.ad
  19. Hi there, I'm creating a platformer game that is similar in art style and theme to Thomas Was Alone. I'm currently using the Phaser.ARCADE Physics system for my game cause it suits the theme well enough. However, I want to implement a jump mechanic that is similar that is similar to Thomas Was Alone. https://www.youtube.com/watch?v=aAfgZrt_93k As of right now, my jump mechanics is a simple: if ((this.player.cursor.up.isDown) && this.player.body.onFloor()) { this.player.body.velocity.y = -300; } What do I do to make it feel less 'space-like'
  20. I had thought about that and it's usually been a habit of mine to have a .move() or .draw() for every object. However, the reason I decided to make a separate movePlayer function on it's own was so that changes in just that one function would reflect in all players. What is the standard way of doing things? Creating player1.move and player2.move or just one movePlayer() function?
  21. @drhayes - Did that and I got this.. Clicking any of the lines gives me the second image. Nevermind.. I was just stupid. The function kept exiting because instead of if (!player.alive) I accidently typed if (player.alive) Programming..huh. xD
  22. Edit: Formatting seems to be a bit screwed up..just ignore the missing brackets and '.' So currently I have a game in which two players move around shooting enemies. This is the current code I have implemented. var preloadfunction loadimage'player1', 'assets/player1.png'; loadimage'player2', 'assets/player2.png'; , createfunction stagebackgroundColor '#000000'; physicsstartSystemPhaserARCADE; rendererrenderSessionroundPixels true; //setting render system to pixel-based thisplayer1 addspritewidth2 40, height60, 'player1'; //adding player1
×
×
  • Create New...