Jump to content

Tilemap createFromObjects, "Invalid objectgroup name given" with Tiled


kurisubrooks
 Share

Recommended Posts

Hi there. I'm an experienced JS dev looking to get into Game Development.
I've started out with a fairly small top-down "rpg" style game. I'm used the program "Tiled" to create the world map.

So far i've been following this tutorial to get started, learn the basics of Phaser, but now i'm unfortunately running into this problem.
This tutorial is about 2 years old, and uses it's own "object" generator, however i'd really like to use Phaser's native `.createFromObjects` function.

My code is as follows;

this.map = this.game.add.tilemap("world");
this.map.addTilesetImage("sheet", "spritesheet");
let map = this.map;

let objects = this.game.add.group();
objects.enableBody = true;

this.map.objects.objects.forEach(function(element) {
    map.createFromObjects(element.name, element.gid, element.properties.sprite, 0, true, false, objects);
});


The error I receive in the console;

Tilemap.createFromObjects: Invalid objectgroup name given: goldCoins
Tilemap.createFromObjects: Invalid objectgroup name given: playerSpawn
Tilemap.createFromObjects: Invalid objectgroup name given: goldCoins
Tilemap.createFromObjects: Invalid objectgroup name given: campFire
Tilemap.createFromObjects: Invalid objectgroup name given: stool
Tilemap.createFromObjects: Invalid objectgroup name given: sign


I've cut out the majority of the code for sake of saving space in this forum post,
but the full code is available here.

 

I've already looked up multiple forum posts, each with their own solutions to fix the bug i'm experiencing, however none have worked.
I've tried replacing the "groups" param with the Tiled object's name, as per this post, but i'm unable to find a fix for this.

I'd appreciate any help anyone may provide for me.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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