Jump to content

crffty
 Share

Recommended Posts

Hi. I'm trying to make my first game with Phaser and I'm trying to get some physics working - global gravity.

I'm not sure whats going on but somethings not working:

 

vaultage.game.prototype = {
  create : function() {
    this.background = this.game.add.tileSprite(0, 0, this.game.width, 360, 'background');
    this.background.autoScroll(-100, 0);

    this.background = this.game.add.tileSprite(0, 290, this.game.width, 8, 'ground');
    this.background.autoScroll(-180, 0);

    this.player = this.add.sprite(30, 230, 'player');
    this.player.animations.add('run');
    this.player.animations.play('run', 10, true);

    // physics engine
    this.game.physics.startSystem(Phaser.Physics.P2JS);
    // gravity
    this.game.physics.p2.gravity.y = 400;

  },

based on a couple tutorials I've been following I was expecting for the 'ground' to fall, but it does not. I'm still really new to Phaser and kinda new to JS, so i figure I'm overlooking something simple.

I actually only need gravity on the player sprite so if you could suggest how to go about that I would appreciate in but would be happy just to get some gravity of any kind to start with.

Thank you in advance for your help.   

Link to comment
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...
 Share

  • Recently Browsing   0 members

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