Jump to content

Procedurally generating a tilemap


seiyria
 Share

Recommended Posts

Currently, I'm trying to take my 2d array and make a tilemap out of it. Unfortunately, I hit a wall right away, and I can't seem to find any examples of doing this. Here's what I've got:

 

  var map = new MapGenerator(pregens.openworld1);  var tilemap = new Phaser.Tilemap(this.game, null, 32, 32, map.worldWidth, map.worldHeight);  tilemap.addTilesetImage('DungeonA2', 'DungeonA2', 32, 32, 0, 0, 0);  tilemap.addTilesetImage('WorldA2', 'WorldA2', 32, 32, 0, 0, 192);

where map basically returns my "world" object. I'm trying to add tileset images but it keeps failing. In my preload state, I have this:

    this.load.spritesheet('DungeonA2', 'assets/sprites/tiles/Dungeon_A2.png', 32, 32);    this.load.spritesheet('WorldA2', 'assets/sprites/tiles/World_A2.png', 32, 32);

so those keys should definitely exist in the cache, but yet it fails with "cannot read property cache of undefined" on tilemap.addTilesetImage.

 

Any ideas what I'm doing wrong?

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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