1

我在创建函数中将重力设置为 1000,如下所示:

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

但是当我在自己的功能中集成射弹时:

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;
        }
    }
} 

弹丸受到重力影响,在弹丸发射时被拖到地面。我将如何使它以直线射击,而其他射击的物体受到重力的影响。

4

0 回答 0