Fatticus Posted July 7, 2016 Share Posted July 7, 2016 I've just started creating a schmup game using the Phaser Weapon plugin and would like to create bullets that cause different damage to the enemy according to which bullet type is selected. How can I set the damage value of a bullet created from the Weapon plugin or find the current damage value ie console.log(??). Link to comment Share on other sites More sharing options...
drhayes Posted July 7, 2016 Share Posted July 7, 2016 Maybe the easiest way is to make an overlap handler that "knows" the damage for the bullets you're checking for. In other words, somewhere in update you have "game.physics.arcade.overlap(enemies, player.weapon1.bullets, this.onBulletsOverlap, null, this);". In "onBulletsOverlap" you know what kind of bullets hit (weapon1's bullets), so you can do the damage you need. Alternately, you can create a custom bullet class and tell the weapon to use it via the "bulletClass" property on the weapon. Link to comment Share on other sites More sharing options...
Fatticus Posted July 8, 2016 Author Share Posted July 8, 2016 Thanks drhayes. I've sorted it using overlap and referencing the key of the weapon. weapon = game.add.weapon(30, 'bullet1'); weapon2 = game.add.weapon(30, 'bullet5'); this.physics.arcade.overlap(weapon.bullets, enemies, this.killEnemy, null, this); this.physics.arcade.overlap(weapon2.bullets, enemies, this.killEnemy, null, this); killEnemy:function(bullet,enemy){ console.log("kill both"); /*===which bullet hit the enemy====*/ console.log(bullet.key); /*===set bullet damage according to bullet key=====*/ var damage; switch(bullet.key) { case 'bullet1': damage = 1; break; case 'bullet5': damage = 10; break; } bullet.kill(); enemy.health -= damage; if(enemy.health <=0) { enemy.kill(); } } } Thanks for your help drhayes. If anyones interested on how to implement this then you can view a very rough shmup code (view source) at http://www.davidbrind.co.uk/spaceshooter/index.html Hope this helps others Link to comment Share on other sites More sharing options...
Recommended Posts