1

I set gravity to 1000 in the create function like so :

game.physics.arcade.gravity.y = 1000;

But then when I intergraded projectiles in its own function:

function shootr(){
    if (canshoot) {
        if (attackTimer< game.time.now) {
            attackTimer = game.time.now + 500;
            var projectile;
            projectile = projectiles.create(
                player.body.x + player.body.width  / 2,
                player.body.y + player.body.height / 2,
                'powerball');

            game.physics.enable(projectile, Phaser.Physics.ARCADE);

            projectile.outOfBoundsKill = true;
            projectile.anchor.setTo(0.5, 0.5);
            projectile.body.velocity.x = 400;
        }
    }
} 

The projectile is being affected by gravity, being dragged to the ground when the projectile is being launched. How would I make it so it shoots in a straight line, while the other objects shot are being affected by gravity.

Ferrybig
  • 18,194
  • 6
  • 57
  • 79
Florin Gusa
  • 63
  • 1
  • 6
  • You are setting `projectile.outOfBoundsKill` to true, but that won't do what you want unless you also set `projectile.checkWorldBounds` to true, as it says in [the documentation](http://phaser.io/docs/2.4.4/Phaser.Sprite.html#outOfBoundsKill). – jja Feb 10 '16 at 11:15

0 Answers0