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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.