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

Full-block tile in arcadeslopes not registering for collision #49

Closed
therladbsgh opened this issue Aug 27, 2017 · 4 comments
Closed

Full-block tile in arcadeslopes not registering for collision #49

therladbsgh opened this issue Aug 27, 2017 · 4 comments

Comments

@therladbsgh
Copy link

I'm currently using the Arcade Slopes tileset (32px) provided in this repository. However, the tileset is showing some bizarre behavior; in particular, the first tile (full-block) is inconsistent in being collide-able.

Below is an example in Tiled of using the tileset in a map:

img1

However, when seen in the actual game, the selection of full-blocks on the top-right is not registered for collisions at all. Also, while the half-blocks are registered for collision when used in the house, it does not register for collision when placed next to a full-block (as seen in the stack of logs next to the house.)

img2

However, the tiles on the stack of logs WILL register for collision if there are other tiles directly adjacent to it. Below is an example in Tiled where I place more vertical half-blocks near the logs:

img3

In this case, when seen in the game, the collisions work as intended (although the tiles in the top-right are still not registered):

img4

I'm not sure if this is a bug, or if there is a specific criteria that needs to be required for full-blocks (and other blocks) to be registered for collision. Below is the relevant code for your reference. Here's the actual link to the repository if more information is needed. I'm also using Phaser CE (v2.8.4).

Game State:

preload() {
    this.game.load.image('sprite', 'assets/sprites/sprite.png');
    this.game.load.spritesheet('arcade-slopes-32', 'assets/map/arcade-slopes-32.png', 32, 32);
    this.game.load.tilemap('map', 'assets/map/example_map.json', null, Phaser.Tilemap.TILED_JSON);
    this.game.load.spritesheet('tileset', 'assets/map/tilesheet.png', 32, 32);
}

create() {
    ...
    const map = this.game.add.tilemap('map');
    map.addTilesetImage('tilesheet', 'tileset');
    map.addTilesetImage('collisions', 'arcade-slopes-32');
    for (let i = 0; i < map.layers.length; i++) {
      if (map.layers[i].name !== 'collisions') {
        map.createLayer(i);
      }
    }
    this.collisionLayer = map.createLayer('collisions');
    map.setCollisionBetween(0, 34, true, this.collisionsLayer);
    this.game.slopes.convertTilemapLayer(this.collisionLayer, 'arcadeslopes');
    this.collisionLayer.debug = true;
}

update() {
    ...
    if (player && player.sprite) {
      this.game.physics.arcade.collide(player.sprite, this.collisionLayer, () => {
        console.log("Hey");
      });
    }
  }
}
@hexus
Copy link
Owner

hexus commented Aug 30, 2017

Hey there, thanks for taking the time to make such a clear example of this issue. I'll hopefully have some time to take a look soon and find out what's going on here.

@hexus
Copy link
Owner

hexus commented Sep 9, 2017

Hey there!

After spending an hour or so trying to debug the plugin with your game running, I've realised it's not the plugin at fault.

Here's the error:

https://github.com/therladbsgh/rpg-web/blob/0dea01e/client/game/room/RoomClass.js#L73

this.collisionsLayer should be this.collisionLayer

As a result, setting the collision flags will then work correctly.

Cheers!

@hexus hexus closed this as completed Sep 9, 2017
@therladbsgh
Copy link
Author

Well, RIP... that was embarrassing. Thanks so much for taking the time.

@hexus
Copy link
Owner

hexus commented Sep 12, 2017

No trouble, it gets the best of us. :)

I am looking to alleviate the need to call this manually at some point, in the future (#45).

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