Jump to content

Tiled tilemap not displaying correctly


aaricpittman
 Share

Recommended Posts

I'm struggling with getting Phaser to use my tilemap that I'm generating using Tiled. I have my game dimensions configured for 640 x 480. In Tiled my map dimensions are 80 x 30 tiles with a tile being 16 x 16. In Tiled things look correct but in the game my sky layer is offset for some reason. However, my ground layer is positioned correctly. I've attached a screenshot of what I'm seeing in the game.

Below is my code for initializing the tilemap and its layers

this.tileMap = this.make.tilemap({ key: `${this.levelKey}-map` })

this.physics.world.setBounds(0, 0, this.tileMap.widthInPixels, this.tileMap.heightInPixels)
this.cameras.main.setBounds(0, 0, this.tileMap.widthInPixels, this.tileMap.heightInPixels)

const skyTiles = this.tileMap.addTilesetImage('level1-sky', `${this.levelKey}-sky`)
this.tileMap.createLayer('sky', skyTiles, 0, 0)

const groundtiles = this.tileMap.addTilesetImage('level1-tileset', `${this.levelKey}-tileset`)

this.groundLayer = this.tileMap.createLayer('ground', groundtiles, 0, 0)
this.groundLayer.setCollisionByProperty({ collides: true })

this.platformLayer = this.tileMap.createLayer('platforms', groundtiles, 0, 0)
this.platformLayer.setCollisionByProperty({ collides: true })

 

screenshot.png

Link to comment
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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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