Single Layout, Multiple Levels. Help w/Tilemaps

Get help using Construct 2

Post » Sat Jan 28, 2017 9:48 pm

Hey guys. I'm creating a simple platformer and I figured, memory-wise using a single layout with multiple instances of the same tilemap might be the best solution for different levels. Is this a correct assumption?

How do I save the tilemap configurations into an array and load them to the appropriate levels in the game?

I'd appreciate it if someone could edit this capx. 8-)
https://www.dropbox.com/s/ctwcooln67707 ... .capx?dl=0

Haven't done much in the capx yet.
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 818
Reputation: 20,779

Post » Mon Jan 30, 2017 12:25 pm

You can save a tile map configuration using the tilemap's 'TilesJSON' expression. You can store it as a string - if I need multiple tilemaps for multiple levels I'll usually use a Dictionary with keys named for each level, and the value set to the TilesJSON for that level.
<iframe frameborder="0" src="https://itch.io/embed/146124?linkback=true&dark=true" width="552" height="167"></iframe>
B
26
S
7
Posts: 254
Reputation: 2,389

Post » Mon Jan 30, 2017 12:55 pm

mrtumbles wrote:You can save a tile map configuration using the tilemap's 'TilesJSON' expression. You can store it as a string - if I need multiple tilemaps for multiple levels I'll usually use a Dictionary with keys named for each level, and the value set to the TilesJSON for that level.


Can you show example too of how to repopulate the map after?
I made different instances of the tilemap but how do I use only one?
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 818
Reputation: 20,779

Post » Tue Jan 31, 2017 5:09 pm

mrtumbles wrote:You can save a tile map configuration using the tilemap's 'TilesJSON' expression. You can store it as a string - if I need multiple tilemaps for multiple levels I'll usually use a Dictionary with keys named for each level, and the value set to the TilesJSON for that level.


I found the download as json action but now how do I save multiple levels?
I'm thinking have all maps in my MAIN MENU layout, save all tilemaps as json then delete all. So the next time a user starts the game the tilemaps will be deleted and accessed from webstorage.
Is this the correct usage? Could someone modify the capx?
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 818
Reputation: 20,779

Post » Wed Feb 01, 2017 6:59 pm

Personally I would create the tilemaps in C2, grab their JSONs one by one, then store them in a dictionary.json which you include as a project file and load on start - rather than writing events to populate the dictionary, which I think would mean you'd have to loop through the levels on start.
<iframe frameborder="0" src="https://itch.io/embed/146124?linkback=true&dark=true" width="552" height="167"></iframe>
B
26
S
7
Posts: 254
Reputation: 2,389

Post » Wed Feb 01, 2017 7:22 pm

mrtumbles wrote:Personally I would create the tilemaps in C2, grab their JSONs one by one, then store them in a dictionary.json which you include as a project file and load on start - rather than writing events to populate the dictionary, which I think would mean you'd have to loop through the levels on start.


Yes that's exactly what I mean't. Sorry my games haven't really been as complex to require the use of the dictionary that's why I'm confused.
Using this dictionary, will it be saved locally when I export this game to Android/iOS or will users be required to download all info from a cloud?
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 818
Reputation: 20,779

Post » Thu Feb 02, 2017 5:47 pm

If the JSON is stored as a project file and loaded on start, the file will be saved locally, yes.
<iframe frameborder="0" src="https://itch.io/embed/146124?linkback=true&dark=true" width="552" height="167"></iframe>
B
26
S
7
Posts: 254
Reputation: 2,389


Return to How do I....?

Who is online

Users browsing this forum: saour and 5 guests