Jump to content

Random tilemap


mk12001
 Share

Recommended Posts

i think it's possible, but it's probably not easy. The most brute force way I can think of is to edit the JSON file within your program. This means parsing the JSON file and replacing the tile entries with a random number that corresponds to one of your desired tiles. This is probably not optimal for anything other than small maps. 

 

Best advice is to take a look at the Phaser source and see how these methods actually work, and then modify them as you need. 

Link to comment
Share on other sites

you can load tilemaps from variables, see my example: 

var nivelsLayers = [    {     "Cam" : {          "height":80,         "layers":[                {                 "data":[ ........ ]    }}, //More levels]var playState = {    preload: function () {        //Create your random        this.game.load.image('tile', "assets/nivels/n" + actualNivel + "-tile.png");        this.game.load.tilemap('carreteraTileMap', null, nivelsLayers[actualNivel - 1]["Cam"], Phaser.Tilemap.TILED_JSON);    },    create: function(){        this.carreteraMap = this.game.add.tilemap('carreteraTileMap');        this.carreteraMap.addTilesetImage('tile');    }}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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