Jump to content

Phaser 2.x Arcade sprite collision bug


Karma Octopus
 Share

Recommended Posts

I am using sprites inside a group as the ground and then I check collision of that group against the player sprite.

 

Now the problem is that when the player sprite tries to move over the next sprite that the ground is made out of is just suddenly stops, like it has collided with and invisible object.

 

In this image the player sprite will move just fine towards the right:
 

post-5919-0-85693600-1395173319.png

But when it reaches the edge of the next floor sprite it stops moving:

post-5919-0-72706700-1395173343.png

Even if the player now jumps up in the air it won't move to the right any more.

This only occurs in 2.0 and up, I have tried it with the latest dev build too, The same thing works fine in 1.1.6.

Here is some code to replicate it:

        private _player: Phaser.Sprite;        private _collisionGroup: Phaser.Group;        create()        {            this.game.physics.startSystem( Phaser.Physics.ARCADE );            this._collisionGroup = this.add.group();            this._collisionGroup.enableBody = true;            this._collisionGroup.physicsBodyType = Phaser.Physics.ARCADE;            for ( var i = 0; i < 15; i++ )            {                var block: Phaser.Sprite = this._collisionGroup.create( i * 64, 300, 'collisionImage' );                block.body.immovable = true;                block.body.allowGravity = false;            }                        this._player = this.game.add.sprite( 200, 200, 'player', 0 );            this._player.anchor.setTo( 0.5, 0.5 );            this.game.physics.enable( this._player, Phaser.Physics.ARCADE );            this._player.body.velocity.x = 50;            this.game.physics.arcade.gravity.y = 600;        }        update()        {            this.game.physics.arcade.collide( this._player, this._collisionGroup );        }
Link to comment
Share on other sites

I tried it with the latest version, sadly it doesn't work. It does work in 1.1.6, I'm not sure if that is of any help.

 

I hope this issue can be fixed, I don't really need any advanced collision handling in this game so it would be totally overkill to use for example p2.

Link to comment
Share on other sites

Right I've spent quite some time looking at this. I always knew WHY it was happening, but there was no easy way to resolve it, because of maintaining the legacy 1.1.3 approach to physics. I believe I've come up with a workable solution that keeps the legacy handling, but stops things like the above from happening. I've made several tests that all work properly now and it'll be part of the 2.0.1 release today.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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