Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add a new tile to a layer, in addition to changing the GID #44

Open
thenick775 opened this issue Dec 1, 2018 · 4 comments
Open

Comments

@thenick775
Copy link

thenick775 commented Dec 1, 2018

I've been playing around with the setTileGid:at: method and I noticed that it does not add a new node to a layer, it only allows you to change the tile texture/GID. I was wondering the general steps that should be taken in adding a new tile into a layer at runtime, specifically how to perform the operations in removeTileAtCoord: in reverse.

Thank you in advance.

@msxnake
Copy link

msxnake commented Dec 1, 2018 via email

@thenick775
Copy link
Author

thenick775 commented Dec 1, 2018

If you don't mind me asking, could you explain why? I know that the removeTileAtCoord: method does remove a tile from a specified layer. What I am trying to accomplish is to have a set of tiles in a layer, make them "passable" for my character, and then make them "unpassable" after the character has moved past them.

@msxnake
Copy link

msxnake commented Dec 2, 2018 via email

@slycrel
Copy link
Owner

slycrel commented Dec 2, 2018

Generally speaking, I have used a separate layer with "invisible" tiles that controls if things are passable or not, then would change the layer properties as msxnake mentions rather than adding or removing tiles directly.
You could definitely write a function to add a tile. I no longer update JSTileMap, but could poke around in the code a little for you given some time. Check out the function +(id) layerWithTilesetInfo:(NSArray*)tilesets layerInfo:(TMXLayerInfo*)layerInfo mapInfo:(JSTileMap*)mapInfo to see how the layer gets initially built for each tile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants