Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Collision glitches and no upward velocity


sarako
 Share

Recommended Posts

I am running into a couple strange problems with my first Phaser project. I stripped what I was working on down to the bare essentials to play with Phaser 1.1.4, but the problems persist:

 

- Collisions will spontaneously stop for a moment, allowing the player to drop through the platform. This usually happens if I switch the focus out of the browser window, but it will also happen at random intervals, especially on my Android phone or my iPad (Chrome or Safari).

 

- New to Phaser 1.1.4, the player fails to gain any y-direction velocity, as if stuck to the horizontal axis of the ground. This worked in Phaser 1.1.3, though with gravity set per physics body as was the custom - I tried that variation as well here, and it didn't work either.

 

What am I missing?

window.onload = function() {        var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'moe', { preload: preload, create: create, update: update, render: render });                var player;                function preload () {            game.load.spritesheet('runner', 'assets/runner.png', 32.5, 38);            game.load.image('ground', 'assets/platform.png');        }                function create () {                        // setup world            game.stage.backgroundColor = '#5A3945';            game.physics.gravity.y = 500;                        // setup stage            platforms = game.add.group();            var ground = platforms.create(0, 500, 'ground');            ground.body.immovable = true;            ground.body.allowGravity = false;                        // setup player            player = game.add.sprite(0, 0, 'runner');            player.name = 'runner';            player.body.collideWorldBounds = true;            player.body.allowGravity = true;        }                function update () {                        // collision detection            game.physics.collide(player, platforms);                        // click in the direction you want the avatar to move - clicking above the avatar to jump            if (game.input.activePointer.isDown) {                game.physics.moveToPointer(player, 400);            }                    }                function render () {            game.debug.renderPhysicsBody(player.body);        }};

Thank you for any help you can provide!

Link to comment
Share on other sites

Hi,

 

I have the same problem with 1.1.4 - From what I can tell this is the cause:

 

if the gravity value is bigger than the velocity (your gravity is 500, your max velocity 400) no movement happens.

(Except if you set bouncing to some other value then 0.)

 

This is really strange and I think it's a bug.

Maybe you can comment on this github issue (in the hopes that rich will have a look, if i am not alone with the problem :) ):

 

https://github.com/photonstorm/phaser/issues/373

 

It's easy to reproduce with the starstruck example (see github issue).

 

You can of course try to work around it by setting bounce to a low value other then zero, or reduce your gravity below the jump-velocity.

(Both not really options for my Jump & Run..)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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