Jump to content

Changin elements on tile map


Recommended Posts

Hi everyone!



In my project i have screen of the gampe when map was create in tile map editor.


Now i want change some element on the map after any action.

For example when the player use tool, some parts of ground will change for another tile elements.


Is any way to get some part of map and change it for another tile?


I found function what can help, but i dont know how to use it in my project.

My project You can see on lifetime.cba.pl

login test password test


Thanks for any ideas! :)


Link to comment
Share on other sites

On this page:


is good tutorial how to implement GID, but i dont know about i must do all steps?

I need XML?


I render map by this way:

  createItems: function() {    //create items    this.items = this.game.add.group();    this.items.enableBody = true;    var item;        result = this.findObjectsByType('item', this.map, 'objectsLayer');    result.forEach(function(element){      this.createFromTiledObject(element, this.items);    }, this);  },
Link to comment
Share on other sites

Yours example Was fine and thanks, but i want get tile from other file than map.


For example when player use tools, i want to get tile from other file and paste it on the map.

But i must try how to get tile or image from other file to variable and this paste to the map.


When i use replace i must have this image or tile on the map.


Thanks for interest. :)

Link to comment
Share on other sites

I think about Yours methods but this is not that wat i want.


When i add to the game tile and dont display it, my map will be smaller, tell me if i am wrong.


I dont have idea how to add tile from other file.Only idea what i have is to add it as sprite:


var tile=image...


var add=this.add.sprite(this.input.activePointer.x + this.camera.x, this.input.activePointer.y + this.camera.y, tile);


Do you thin it will be good solution? When i add sprite to tile on map it not will be double and the game not will be burdened?



Maybe someone have idea how to change tile from other file/image, so tell me pls :)

Link to comment
Share on other sites



I found answer to my problem. It Was very easy..

tilex = this.backgroundlayer.getTileX(this.game.input.activePointer.worldX);tiley = this.backgroundlayer.getTileY(this.game.input.activePointer.worldY);this.map.putTile(494, tilex, tiley)}

I think about number 494 is index of tile on the map, but this is index of tile on tileset from my map was created and there are tiles what i can add to the map :)


But now i have one question else.

put tile is getting tile from frist tileset what i used to create map, but how to change tileset to other what wah using to create map?


in my map i have 3 tileset images, but now i can get tile only from first, how i can change it?

Link to comment
Share on other sites

  • 2 months later...

Hi everyone.


I want to refresh the topic. I have a map made in tileeditor of multi tileset.


When player click on map i want to att tile this method: putTile(tile, x, y, layer).


TIle is a number tile on tileset, but is any way to chose from which tileset get tile?


Please help and give any ide ho to do that :)



Link to comment
Share on other sites


  • Recently Browsing   0 members

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