Another Tilemap question: copy all data to new tilemap?

0 favourites
  • 14 posts
From the Asset Store
Kids Game
$49 USD
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • 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.

  • 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

  • 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.

  • 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.

  • 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.

  • Oh I see what you mean, no there are wall graphics and floor graphics and they're never the same.

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

    The tile numbers are numbered like this:

     0  1  2
     3  4  5
     6  7  8
     9 10 11[/code:rdxv0r8t]
    
    [url=https://dl.dropboxusercontent.com/u/5426011/examples31/partial_solid_tilemap.capx]https://dl.dropboxusercontent.com/u/542 ... lemap.capx[/url]
  • Ok, here's an example. Just set toErase to a list of tiles that are decoration.

    The tile numbers are numbered like this:

     0  1  2
     3  4  5
     6  7  8
     9 10 11[/code:hz1g9x4w]
    
    [url=https://dl.dropboxusercontent.com/u/5426011/examples31/partial_solid_tilemap.capx]https://dl.dropboxusercontent.com/u/542 ... lemap.capx[/url]
    

    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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

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

    The tile numbers are numbered like this:

     0  1  2
     3  4  5
     6  7  8
     9 10 11[/code:3j2pldre]
    
    [url=https://dl.dropboxusercontent.com/u/5426011/examples31/partial_solid_tilemap.capx]https://dl.dropboxusercontent.com/u/542 ... lemap.capx[/url]
    

    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.

  • R0J0hound I could feasibly get this working by cloning all of the json for tilemap1 into a clone of the tilemap rather than a new instance, but the clone won't take the json from the first object tilemap?

  • Zebbi

    I haven't used the raycast plugin so I don't know if there's anything amiss. Picking the newest uid should work but I guess it depends on how you do it.

  • Zebbi

    I haven't used the raycast plugin so I don't know if there's anything amiss. Picking the newest uid should work but I guess it depends on how you do it.

    Is it actually possible to clone all the tiles to a complete different clone tilemap, even if it set-up exactly the same way?

    EDIT: Ahh, I changed it to "set copy as Tilemap.TilesJSON" instead of "set copy as Tilemap.asJSON" and it worked! Now, how do I invert this? It would be easier, if I have, say two tiles out 300 that are solid to be picked, destroyed, and the rest left, whilst duplicating the solids on a new tilemap, wouldn't it?

  • R0J0hound Or better yet, can the tiles be deleted with an "all except" routine, that deletes all of the tiles, except for the ones listed in a toKeep variable?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)