PixelProgrammer

Members
  • Content count

    26
  • Joined

  • Last visited

About PixelProgrammer

  • Rank
    Member
  • Birthday
  1. @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?
  2. @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?
  3. 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
  4. 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.Weapon.prototype); and it seems to work. However, when I try to fire my bullet I get the following error Cannot read property 'getFirstExists' of null at Pistol.Phaser.Weapon.fire (phaser.js:101053)
  5. 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 want to kill that bullet? How would I pass the specific bullet that collided with the enemy into a function? This is what I've tried: game.physics.arcade.collide(this.weapon[this.currentWeapon], this.enemies, function(bullet, enemy) { bullet.kill(); }, null, this); However the above code doesn't work. Bullet is undefined. What do I do?
  6. @drhayes Yup. onInputUp is what I was looking for.
  7. @samme Awesome! This is exactly what I wanted.
  8. @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 way to access a button object's callback function. Such as playButton.callbackFunction()//runs play function. Where does phaser save the callback functions? Is it within the object itself or somewhere else?
  9. 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 (controller.peressed.A_Button){ buttonArray[currentIndex].callbackFunction() }
  10. @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.velocity.x = 300; player.animations.play('right'); } else { player.body.velocity.x = 0; player.animations.stop(); player.frame = 2; } } I'll only keep this as a temporary solution. I'll definitely review it again and change it to more like what you've said.
  11. 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 right this.player_1.animations.play('right'); } if(this.pad1.justPressed(Phaser.Gamepad.XBOX360_A)&& this.player_1.body.onFloor() ){ this.player_1.body.velocity.y = -999; //jump } this.player_1.weapon.fireAngle = -(90 + 90 * -this.pad1.axis(Phaser.Gamepad.XBOX360_STICK_RIGHT_X)); if(this.pad1.isDown(Phaser.Gamepad.XBOX360_RIGHT_TRIGGER)||this.pad1.justPressed(Phaser.Gamepad.XBOX360_RIGHT_BUMPER)) { this.player_1.weapon.fire(); } }, movePlayer1: function () { //player 2 controller if(game.input.gamepad.supported && game.input.gamepad.active && game.input.gamepad.pad2.connected) { this.indicator2.animations.frame = 0; } else { this.indicator2.animations.frame = 1; } if(this.pad2.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_X)< -0.1){ this.player_2.body.velocity.x = -300; this.player_2.animations.play('left'); } if(this.pad2.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_X)>0.1){ this.player_2.body.velocity.x = 300; this.player_2.animations.play('right'); } if(this.pad2.justPressed(Phaser.Gamepad.XBOX360_A)&& this.player_2.body.onFloor() ){ this.player_2.body.velocity.y = -999; } this.player_2.weapon.fireAngle = -(90 + 90 * -this.pad1.axis(Phaser.Gamepad.XBOX360_STICK_RIGHT_X)); if(this.pad2.isDown(Phaser.Gamepad.XBOX360_RIGHT_TRIGGER)||this.pad2.justPressed(Phaser.Gamepad.XBOX360_RIGHT_BUMPER)){ this.player_2.weapon.fire(); } } , I feel that this isn't the best way to code for two player movement. What would you do differently?
  12. @Legomite Theoretically it should cost less since it wouldn't have to render it.
  13. @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.
  14. 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?
  15. 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;