• Content Count

  • Joined

  • Last visited

  1. willdta

    Fire Weapons with a Group

    Thanks for the suggestion! What exactly would the code look like? I'm not sure where to call fire
  2. willdta

    Fire Weapons with a Group

    So I have a group of AI's and I'm trying to have them auto firing. I'm trying to use the tracksprite method but I cannot get it to work with groups. Is there a workaround or method that you can call to track groups? // Create enemies = game.add.group() enemies.create(150,500,'hilary2') enemies.create(150,700,'hilary2') enemyWeapon = game.add.weapon(30, 'shuriken') // Weapon Methods enemyWeapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS enemyWeapon.bulletSpeed = 200 enemyWeapon.fireRate = 1200 enemyWeapon.autofire = true enemyWeapon.trackSprite(enemies, 30, 30, true)
  3. willdta

    Shooting Bullets Automatically

    What I'm trying to achieve is having an enemy shoot bullets randomly with a time interval. Right now I just have a fire method setup on space-bar for my main player sprite but I want to have enemy sprites shooting bullets automatically. Is there a method/example that allows you to do so?
  4. willdta

    Fire Weapon Based Off Sprite's Direction

    Thanks a lot mate! Works like a charm.
  5. willdta

    Fire Weapon Based Off Sprite's Direction

    Appreciate it! However it doesn't work
  6. willdta

    Fire Weapon Based Off Sprite's Direction

    I have that set, unfortunately it doesn't work
  7. I'm trying to shoot a weapon in whatever direction the character is facing. Through looking around, I've found some examples using fireAngle but I'm not sure how to incorporate it to work with my code. Here is my character move function along with a weapon fire on spacebar. Where should I put the fireAngle to work correctly? Thanks player.body.velocity.x = 0; player.body.velocity.y = 0; if (cursors.left.isDown) { player.body.velocity.x = -300; player.animations.play('left') } else if (cursors.right.isDown) { player.body.velocity.x = 300; player.animations.play('right') } else if (cursors.up.isDown) { player.body.velocity.y = -300; player.animations.play('up') } else if (cursors.down.isDown) { player.body.velocity.y = 300; player.animations.play('down') } if (fireButton.isDown) { weapon.fireAngle = Phaser.ANGLE_LEFT; weapon.fireAngle = Phaser.ANGLE_RIGHT; weapon.fireAngle = Phaser.ANGLE_UP; weapon.fireAngle = Phaser.ANGLE_DOWN; weapon.fire(); }
  8. willdta

    Kill a sprite with Collision

    Using Phaser IO, I'm trying to kill off another sprite that's currently not in a collision detection. I have a collision set with the player sprite and a treasure chest and what I want to do is on collision with the treasure chest, kill off another sprite to unlock a level but that sprite is not set in the collision. How do you got about handle 3 way collisions where 1 sprite is not included with the collision? The 3 items are player, treasure, and levelUnlock player is colliding with treasure game.physics.arcade.collide(player, treasure, this.spawnWeapon, null, this) game.physics.arcade.collide(player, treasure, this.spawnLevel, null, this) spawnWeapon: function(player, treasure) { this.enableWeapon = true treasure.kill() } spawnLevel: (player, levelUnlock) => { if (this.enableWeapon) { levelUnlock.kill() }