Jump to content

Inverse gravity, walk on ceiling


MichaelD
 Share

Recommended Posts

Hey guys,

 

I was wondering if something like this: http://forum.unity3d.com/threads/inverting-gravity-to-walk-on-the-ceiling.35271/

 

can be done with Phaser.

 

Does anyone have any example of this functionality, or ideas how should I implement this?

 

I'm thinking rotating the character and then applying negative gravity, with a ceiling collision to prevent it from "falling" upwards.

 

What do you think?

Link to comment
Share on other sites

Yeah thanks I ended up doing the following:

var player = game.add.sprite(0, 0, "andy");    player.y = game.height / 2 - player.height / 2;    player.anchor.setTo(0.5, 0.5);    game.physics.enable(player, Phaser.Physics.ARCADE);    player.body.collideWorldBounds = true;    player.body.allowGravity = true;    player.body.checkWorldBounds();    player.body.bounce.y = 0.1;    player.body.bounce.x = 0.1;    player.body.gravity.y = 2000;    player.inverted = false;function inverseGravity() {    if (reg.player.inverted === false) {        reg.player.angle = -180;        reg.player.body.gravity.y = -2000;        reg.player.inverted = true;    } else {        reg.player.angle = 0;        reg.player.body.gravity.y = 2000;        reg.player.inverted = false;    }}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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