Another Tilemap question: copy all data to new tilemap?

Get help using Construct 2

Post » Wed Feb 10, 2016 1:34 am

Is there a way to "clone" a tilemap object and keep every last piece in tact? It seems pointless to redo everything when I'm trying to just get a solid and a background going, especially with how large the map is that I'm working on.
B
25
S
6
G
6
Posts: 262
Reputation: 3,690

Post » Wed Feb 10, 2016 1:53 am

Solved, easy solution:

1) Clone the Tilemap
2) Save using "Save As Project"
3) Go to the XML file where the original Tilemap is (the "Layouts" folder)
4) Copy the entire <instance> block
5) Find the new Tilemap <instance> and write down the name and UID
6) Paste the block you copied in it's stead, and change the name and UID back to what it should be
7) Enjoy
B
25
S
6
G
6
Posts: 262
Reputation: 3,690

Post » Wed Feb 10, 2016 3:06 am

I'm also going to point out that changing tiles (in my case I needed solid tiles on one Tilemap and floor tiles on another) is as simple (yet tedious) as opening the XML in Notepad++, copying the tile data string (the long line of numbers and commas), then paste them into a new file. Replace solid numbers with "-1". IE: if your wall tile is "45", in Notepad++ open "find and replace, and look for ,45, and replace with ,-1, (include the commas in case the tile numbers are super high, this way lower numbers will not change when you don't want them to).

Do the same with floor tiles in the OTHER string.

When done, copy the string back to the main XML file, save, and load your project file.
B
25
S
6
G
6
Posts: 262
Reputation: 3,690

Post » Wed Feb 10, 2016 4:14 am

Are the tiles you want to be solid and the ones you don't want to be solid always the same? Like certain tiles no matter where they are placed should not be solid but decoration.

If that's the case you could copy the tilemap when the game runs and erase all the decoration tiles and leave the solid ones. Then make the duplicate invisible and make it solid. Basically you'd use two for loops and erase certain tile values.
It would save you time if you wanted to make drastic changes to the map. Of course it wouldn't work if you wanted hidden walls I suppose, but even then you could mark those in another way.
B
89
S
30
G
95
Posts: 5,154
Reputation: 63,444

Post » Wed Feb 10, 2016 4:20 am

It's the same graphics, but the walls are always walls, and the floors should always be floors. My issue is there are a lot of tiles that will be solid and a lot that are not, so it's a bit easier to just edit them manually (in notepad++). I can't stand things being out of order lol. Things just get too complicated when I make games, so I try to make it easy on myself for later, even if in the moment it's long and tedious.
B
25
S
6
G
6
Posts: 262
Reputation: 3,690

Post » Wed Feb 10, 2016 4:21 am

Oh I see what you mean, no there are wall graphics and floor graphics and they're never the same.
B
25
S
6
G
6
Posts: 262
Reputation: 3,690

Post » Wed Feb 10, 2016 8:36 pm

Ok, here's an example. Just set toErase to a list of tiles that are decoration.

The tile numbers are numbered like this:
Code: Select all
 0  1  2
 3  4  5
 6  7  8
 9 10 11


https://dl.dropboxusercontent.com/u/542 ... lemap.capx
B
89
S
30
G
95
Posts: 5,154
Reputation: 63,444

Post » Sun Jan 22, 2017 1:17 am

R0J0hound wrote:Ok, here's an example. Just set toErase to a list of tiles that are decoration.

The tile numbers are numbered like this:
Code: Select all
 0  1  2
 3  4  5
 6  7  8
 9 10 11


https://dl.dropboxusercontent.com/u/542 ... lemap.capx

@R0J0hound Quick question, how can I reference the duplicate tilemap in the events? I've tried to do it by picking the most recent UID, but isn't working, I even tried to reference it via a function that waits until it's cleared the tiles over. I want to do a tracing check only on the new tilemap, but it isn't seeing it, only the original tilemap instance.
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Post » Sun Jan 22, 2017 7:28 pm

@R0J0hound basically the tracer isn't seeing the solid tiles on the second map, it just sees the enemies, I've tested for nth and used Tilemap.Count and Tilemap.Count+1 but the raycaster isn't seeing the second tilemap, just the enemies. It should work, though, and I can only imagine I'm not picking the new instance properly?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Post » Sun Jan 22, 2017 8:26 pm

R0J0hound wrote:Ok, here's an example. Just set toErase to a list of tiles that are decoration.

The tile numbers are numbered like this:
Code: Select all
 0  1  2
 3  4  5
 6  7  8
 9 10 11


https://dl.dropboxusercontent.com/u/542 ... lemap.capx

I've even tried using a clone of the tilemap as tilemap2, and tried to load the tiles to that just for show, and it doesn't load the tiles in, why? If I remove the part that creates a second instance and run the trace check, it's fine, it detects just the solids.
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Next

Return to How do I....?

Who is online

Users browsing this forum: Jhorbam, Yahoo [Bot] and 8 guests