Sign in to follow this  
Chtull

How to change gravity?

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.