Jump to content

Tilemap Layer Issues


chrisoffiong
 Share

Recommended Posts

var self = this
this.map = this.add.tilemap('map')
    let tilemap = this.map.addTilesetImage("Cave", 'level_1')
    this.ground = this.map.createStaticLayer('Ground', tilemap).setDepth(-1)
    let rocks = this.map.createStaticLayer('Rocks', tilemap, 0, 0)
    this.map.setCollision(1214,true, 'Rocks')
 
    rocks.immovable = true;
    // rocks.collideWorldBounds = true
    console.log(rocks)
    function addPlayer(self, playerInfo) {
        player = self.physics.add.sprite(playerInfo.X, playerInfo.Y, 'player')
        player.setCollideWorldBounds(true);
        player.onWorldBounds = true;
        self.physics.add.collider(player, rocks)
        
    }

Hey guys I'm having issues getting the top rock layer to have a collider effect. I've been lurking here and have tried the numerous solutions of all the resources here to no avail.

I've played around with changing whether it was this.map.setCollision or rocks.setCollision, but I'm certain the index for the rocks in the tilemap is 1214. 

Any insight on this issue will save me a great headache. Thanks in advance guys!

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