slycrel / JSTileMap

TMX Map viewer for SpriteKit
Other
212 stars 34 forks source link

Edit in runtime #18

Closed pedromoto4 closed 8 years ago

pedromoto4 commented 10 years ago

Hi all well, I have a doubt, it is possible to edit the maps at runtime? I'd like to see more documentation on the project, there is some place where I can find?

very grateful

slycrel commented 10 years ago

Yes, you can edit the map at runtime. Your best bet to understand the functionality is to look at and run the sample code provided with the library. If you want to dynamically generate maps in an advanced, fully custom way, have a look at the TMXGenerator functionality found in the cocos2d extensions repository on github (it should work with a little tweaking without cocos2d).

pedromoto4 commented 10 years ago

hi slycrel sorry again for bothering but I'm enjoying JSTileMap of your library: D. But I'm having trouble changing the map at runtime. What I meant was changing the tiles in memory and redraw the map. can you give me an example of how I can do this in JSTileMap? I'm studying your code but there are some things we do not understand. So if you help me I would be immensely grateful.

slycrel commented 10 years ago

If you want to change out the tileset, you can change the tiles that are loaded. Everything to do with the actual tileset is found in the TMXTilesetInfo object. This controls what tiles are available and what gid's the tiles use. Then the TMXLayer and TMXLayerInfo control which tiles are placed where, using the tileset information.

Do you want to add new tiles to the map dynamically? There is a method to remove them, but I'm not sure there is one for adding them dynamically, though it shouldn't be too bad to add such a method.

See also this link, and browse your TMX map's XML for more information about this. https://github.com/bjorn/tiled/wiki/TMX-Map-Format

pedromoto4 commented 10 years ago

Hi slycrel, I already understand some of the basic things. There was not a method to add a Tile. But I already created :) I'll take a look at the TMX-Map-Format but I will continue to have your JSTileMap as reference. Good work and thanks for the help :8ball:

ghost commented 10 years ago

Please share your code for adding tiles

pedromoto4 commented 10 years ago

Yes I can share, but before that I want to solve some compatibility problems with ios 7

ghost commented 10 years ago

Progress?:-)

msxnake commented 10 years ago

Yes, I am making a game with Swift and jstilemap. It would be very apreciate to share the code for change a tile at runtime. Like Terraria. A function as setTileGidatCoord(tile: int32,pos: CGpoint)

slycrel commented 9 years ago

@pedromoto4 do you mind sharing your code for your add method? It sounds like a number of people would like to use such a method.

slycrel commented 8 years ago

Added with #43

thenick775 commented 6 years ago

A quick question, this method only changes the texture of an already existing tile in the layer if I am correct. Is there a way to add an entirely "new" tile to the layer using an existing gID like this method does? For example, I have a walls layer the player is not allowed to pass through, this method doesn't do anything to the layer (doesn't add a new tile itself) if an existing clear tile is not there to change. I would like my player to be able to walk through the tile I want to change in my walls layer before I add a new tile, but not be able to after I add a new tile at that coordinate. Thank you for your time!