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

Collision help


Recommended Posts

Hi friends, new to the forum and to Phaser.


Basically I'm trying to get my bearings and right now I'm just sorta turning the "Making your first Phaser game" tutorial http://www.photonstorm.com/phaser/tutorial-making-your-first-phaser-game into a more RPG-style dealy. 


My issue is that my sprite-to-sprite collisions seem to be working well, but if say I walk into a sprite headed right, bump into another sprite and then go a bit up or a bit down, sometimes I can continue through the sprite by heading further right.

I don't have this problem with tileset collisions.


Here's what I have for movement:


//LEFT            if (cursors.left.isDown) {                if (player.body.touching.left) {                    player.x += 3;                }                else {                    player.body.velocity.x = -100;                    player.animations.play('left');                }//RIGHT            } else if (cursors.right.isDown) {                if (player.body.touching.right) {                    player.x -= 3;                }                else {                    player.body.velocity.x = 100;                    player.animations.play('right');                }//UP                             } else if (cursors.up.isDown) {                if (player.body.touching.up) {                    player.y += 3;                }                else {                    player.body.velocity.y = -100;                    player.animations.play('stand');                }//DOWN                            } else if (cursors.down.isDown) {                if (player.body.touching.down) {                    player.y -= 3;                }                else {                    player.body.velocity.y = 100;                    player.animations.play('stand');                }            }             /*else if (cursors.up.isUp)    {        player.body.velocity.y = 0;        player.animations.stop();    }    else if (cursors.down.isUp)    {        player.body.velocity.y = 0;    }*/            else {                //  Stand still                player.animations.stop();                player.frame = 4;                player.body.velocity.x = 0;                player.body.velocity.y = 0;            }        }
And for collisions:
game.physics.collide(player, mans);
Is it something I did? Am I doing something really inelegant and unnecessary or something? Should I add something with overlaps?
Thanks in advance.
Link to comment
Share on other sites

1.1.3 (and previous) had issues where sprites could be forced into each other and into tiles if "pushed hard enough". if you search the forums you'll find threads on this issue.


the physics in 1.1.4 was re-written to fix this. unfortunately, at present, issue #362 means that some collisions don't seem to happen at all.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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