janmagaraes Posted March 16, 2014 Share Posted March 16, 2014 I am very new in the html5 and game development and I am very impressed with the engines, specially Phaser. I am developing a 2D game based on the Tank example available at http://examples.phaser.io/. Currently, I am trying to physics to the bullet group, but I read in the post from yesterday that is not possible http://www.html5gamedevs.com/topic/4800-how-to-add-velocity-to-a-group/. The idea is to shoot when when clicked and the bullets should lose height and speed as it cross the screen.Here is revelant part of the code:function create() {... // Our bullet group bullets = game.add.group(); bullets.createMultiple(30, 'dude'); bullets.setAll('anchor.x', 0.5); bullets.setAll('anchor.y', 0.5); bullets.setAll('outOfBoundsKill', true);function update() { if (game.input.activePointer.isDown) { // Boom! fire(); }}function fire () { if (game.time.now > nextFire && bullets.countDead() > 0) { nextFire = game.time.now + fireRate; var bullet = bullets.getFirstDead(); bullet.reset(weapon.x, weapon.y); bullet.rotation = game.physics.moveToPointer(bullet, 1000); }}Any idea of how to implement it ?Regards Link to comment Share on other sites More sharing options...
rich Posted March 16, 2014 Share Posted March 16, 2014 After you do getFirstDead, you can enable the bullet for physics then (game.physics.arcade.enable(bullet)) and then do whatever physics related things you need to it. janmagaraes 1 Link to comment Share on other sites More sharing options...
Recommended Posts