Jump to content

How to change gravity?


Chtull
 Share

Recommended Posts

Hello,

I'm playing around with the phase3 tutorial. My intention is to have a moving object, that is not affected by gravity (or has a different gravity).
I’m not that good with javascript, therefore it is most likely a stupid failure, but maybe someone can correct me?
 
Here’s the code example:

    var config = {
        type: Phaser.AUTO,
        width: 800,
        height: 600,
        physics: {
            default: 'arcade',
            arcade: {
                gravity: { y: 300 },
                debug: false
            }
        },
        scene: {
            preload: preload,
            create: create,
            update: update
        }
    };

    var star;
    var game = new Phaser.Game(config);

    function preload ()
    {
        this.load.image('sky', 'assets/sky.png');
        this.load.image('star', 'assets/star.png');
    }

    function create ()
    {
        this.add.image(400, 300, 'sky');

        star = this.physics.add.sprite(100, 450, 'star');
        star.setGravity(0,0);

    }

    function update ()
    {
    }

 

Why is the star still affected by gravity?

Thank you so much for checking,
 
Chtull
Edited by samme
format
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...