erest0r Posted July 19, 2016 Share Posted July 19, 2016 Hello i'm having a problem with attribute autofire in a Phaser.Weapon, i set it to true but it doesn't start to fire, i tried that in the page example: http://phaser.io/examples/v2/weapon/fire-rate#gv and added this line in the create method after creating the weapon. weapon.autofire = true; But it doesn't work. Link to comment Share on other sites More sharing options...
Clem Posted July 19, 2016 Share Posted July 19, 2016 Actually what you have to do is to start the "first" fire by yourself with a "weapon.fire();". Then if the autofire is set to "true", the weapon will fire again depending on the "weapon.fireRate". Link to comment Share on other sites More sharing options...
erest0r Posted July 20, 2016 Author Share Posted July 20, 2016 Sorry man, it's not working, click on the link i provided and try it yourself. Link to comment Share on other sites More sharing options...
Clem Posted July 21, 2016 Share Posted July 21, 2016 It took me a little time to figure it out but now I have the solution ! Actually the way "autofire" works is pretty weird but it makes sense somehow... To make it work you have to : - Set your "weapon.fireRate" in the "create" function, for example set it to 1000 to have a new shot each 1000 ms (1 s) - Set "weapon.autofire" to true, in the "create" function - Then in the "update" function, you have to put a weapon.fire(); And what will happen next is that the weapon will only shoot each 1000 ms (1 s). Link to comment Share on other sites More sharing options...
Recommended Posts