Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(1.1.5) Collision callback triggers only when sprite hits a corner of a tile #467

Closed
mandarinx opened this issue Feb 21, 2014 · 1 comment

Comments

@mandarinx
Copy link
Contributor

This can be reproduced by using the mario collide example. Add a callback to physics.collide() and you'll see that it doesn't trigger when the player hits the ground or hit any tile perpendicularly. It will only trigger when hitting a corner of a sprite. Try standing right next to a green pipe, jump and when falling down move slightly towards the pipe.

In 1.1.5, the first few lines in ArcadePhysics.js:collideSpriteVsTilemapLayer() looks like this:

this._mapData = tilemapLayer.getTiles(sprite.body.left, sprite.body.top, sprite.body.width, sprite.body.height, true);

if (this._mapData.length === 0)
{
    return;
}

if (this._mapData.length > 1)
{
    this.separateTiles(sprite.body, this._mapData);
}
else
{
    var i = 0;

    if (this.separateTile(sprite.body, this._mapData[i]))
    {

While, in 1.1.3 the same function starts with these lines:

this._mapData = tilemapLayer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true);

if (this._mapData.length === 0)
{
    return;
}

for (var i = 0; i < this._mapData.length; i++)
{
    if (this.separateTile(sprite.body, this._mapData[i]))
    {

I tried fixing this by copy-pasting the lines from 1.1.3, and now the callback is triggered every time a sprite hits a tile.

@photonstorm
Copy link
Collaborator

Thanks. Fixed for 1.1.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants