How i can do collide everything inside on a layer with my character

Recommended Posts

Hi guys i have a tilemap with 4 layers(ground, water, roads, others) and a sprite with my character. how i do would for my character can collide with everything inside on others(layer),every layer use a different sprite, example ground use ground.png, water water.png etc, i have this code ( i use

/* globals __DEV__ */
import Phaser from 'phaser'
import Mushroom from '../sprites/Mushroom'
import Link from 'phaser-link'

export default class extends Phaser.State {
  super() {
  init () {}
  preload () {
    this.load.image('terrain', '../../assets/sprites/tileset_basic_terrain.png', 16, 16)
    this.load.image('this.others', '../../assets/sprites/tileset_other.png', 16, 16)
    this.load.image('water', '../../assets/sprites/tileset_water.png', 16, 16)
    this.load.tilemap('tilemap', '../../assets/map/overworld_01.json',null,Phaser.Tilemap.TILED_JSON)
    this.load.spritesheet('character', '../../assets/sprites/character.png', 16, 32, 1)

  create () { ='tilemap')'tileset_basic_terrain', 'terrain', 16, 16)'tileset_other', 'this.others', 16, 16)'tileset_water', 'water', 16, 16)

    this.ground ='Ground')

    this.water ='Water')

    this.others ='Others')
    this.roads ='Roads')
    this.roads.resizeWorld(),1000, true, this.others)
    this.physics.startSystem( Phaser.Physics.ARCADE ) = this.add.existing(new Link({
        key: 'character',
        controls: true,
  update() {, this.others);
  render () {
    if (__DEV__) {
      //this.debug.body(this.player,16, 32)


But sometime when i try test the collision between the player and layer others, this don't work correctly, collide in a blank block in somewhere place for example left and top place, but in bottom and right place the collide work correctly. for create my map i use tilemap editor 1.0.3

Images of example:


there i can't move more to right:



there i can't move more to bottom:



there work correctly



Sorry for my bad english. and thanks


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.