Amberalex

Members
  • Content count

    6
  • Joined

  • Last visited

  1. Amberalex

    Fire Weapon Based Off Sprite's Direction

    In that case I need more context
  2. Amberalex

    Fire Weapon Based Off Sprite's Direction

    I recommend use trackSprite for rotation of weapon's bullet, for example: weapon = game.add.weapon(10, 'bullet'); weapon.trackSprite(player, 0, 0, true); It's seems the easiest way to solve the problem.
  3. Amberalex

    Fire weapon via loop

    Hello. I am using phaser weapon plugin and want fire in forEach loop: var weapon = game.add.weapon(10, 'bullet'); enemies.forEachAlive(function(enemy){ if(enemy.name == 'p1'){ player.rotation = game.physics.arcade.angleBetween(player, ednemy); weapon.fireAtSprite(enemy); } }); If I have 5 enemies in a row, and only 3 if them have name = p1, after executing this code, player sprite is rotate to the last enemy, but there is only one bullet. What can I do here?
  4. Amberalex

    Set bullet property

    Found solution via getFirstDead() Any other suggestions?
  5. Amberalex

    Set bullet property

    Hello. I am using weapon.fire() function and I want to set special property for bullet, that apear after calling this function. I tried to use forEach: weapon.bullets.forEach(function(bullet){ if(bullet.target == undefined){ bullet.taget = 'prop1'; return; } }); weapon.fire(); but this does not work.
  6. Amberalex

    Problem with Weapon

    Hello. I am trying to use Weapon class, and I found some problem. Here is my code: var game = new Phaser.Game(640, 360, Phaser.AUTO); var GameState = { preload: function(){ game.load.image('player', 'assets/images/player.png'); game.load.image('enemyBody', 'assets/images/enemyBody.png'); game.load.image('bullet', 'assets/images/bullet.png'); }, create: function(){ this.player = game.add.sprite(game.world.centerX, game.world.centerY, 'player'); this.enemy = game.add.sprite(500, 200, 'enemyBody'); //this.makeShoot(); this.enterKey = this.game.input.keyboard.addKey(Phaser.Keyboard.ENTER); this.enterKey.onDown.add(this.pressEnterKey, this); }, pressEnterKey: function(){ this.makeShoot(); }, makeShoot: function(){ this.player.rotation = this.game.physics.arcade.angleBetween(this.player, this.enemy); this.bullet = game.add.weapon(1, 'bullet'); this.bullet.trackSprite(this.player, 0, 0, true); this.bullet.fire(); } }; game.state.add('GameState', GameState); game.state.start('GameState'); When code is executing, after the FIRST press Enter bullet appears at (0, 0), then bullets appear at player position. If I remove comment from commented line it works perfect. Where is my mistake?