MichaelD Posted December 8, 2015 Share Posted December 8, 2015 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? Tilde 1 Link to comment Share on other sites More sharing options...
ekeimaja Posted December 8, 2015 Share Posted December 8, 2015 I think it is easiest way to do that as you described. I would make it so. Tilde 1 Link to comment Share on other sites More sharing options...
drhayes Posted December 8, 2015 Share Posted December 8, 2015 Yes. Physics bodies each have a gravity property you can set. I'd try it. Tilde 1 Link to comment Share on other sites More sharing options...
MichaelD Posted December 9, 2015 Author Share Posted December 9, 2015 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 More sharing options...
Recommended Posts