Group Set Velocity Y

Demonstrates how to set the vertical velocity for all members of an Arcade Physics group, including using an optional step value to incrementally increase the speed for each member.

Group Set Velocity Y, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.load.image('ball', 'assets/demoscene/ball-tlb.png');
    }

    create ()
    {
        const group = this.physics.add.group({
            key: 'ball',
            frameQuantity: 28,
            gridAlign: {
                x: 14,
                y: 14,
                width: 28,
                height: 1,
                cellWidth: 28
            },
            bounceY: 1,
            collideWorldBounds: true
        });

        group.setVelocityY(300, 10);
    }
}

const config = {
    scale: { mode: Phaser.Scale.FIT },
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    parent: 'game-container',
    physics: {
        default: 'arcade',
        arcade: {
            debug: false,
            gravity: { y: 100 }
        }
    },
    scene: Example
};

const game = new Phaser.Game(config);

More in Arcade132 examples