Question about tilemap, and json

Get help using Construct 2

Post » Thu Apr 14, 2016 7:45 pm

Hi. I have a layout , which loads a tilemap tile by tile, and i want to store it to load it's state in the next layout.

I've tried using the actions download, and load in the next layout, without any sucess. I've also tried to store in a text variable the tilemap.tilesJSON, and set the tilemap from it in the next layour, and didn't work.

What i'm doing wrong? Thanks for your time.
B
7
S
2
G
1
Posts: 17
Reputation: 534

Post » Thu Apr 14, 2016 7:53 pm

I was doing almost that, saving a tilemap as json to dictionary or array, and then load it when I need it - on same or different layout, without any problems whatsoever (did not test with newest stable C2 version). So probably there is a problem in your events, cause I don't think Ashley changed something in tilemap recently.
ImageImageImageImage
B
157
S
64
G
41
Posts: 2,590
Reputation: 34,640

Post » Thu Apr 14, 2016 8:31 pm

shinkan wrote:I was doing almost that, saving a tilemap as json to dictionary or array, and then load it when I need it - on same or different layout, without any problems whatsoever (did not test with newest stable C2 version). So probably there is a problem in your events, cause I don't think Ashley changed something in tilemap recently.


Can you explain me the exact process of it? I've tried with different approachs but i haven't done it yet.
B
7
S
2
G
1
Posts: 17
Reputation: 534

Post » Thu Apr 14, 2016 8:47 pm

Here's array solution

To save
On key S pressed -> Array: Set value at 0 to Tilemap.AsJSON

To load
On key L pressed -> Tilemap: Set JSON string from Array.At(0)

and that's it.
ImageImageImageImage
B
157
S
64
G
41
Posts: 2,590
Reputation: 34,640

Post » Thu Apr 14, 2016 11:16 pm

shinkan wrote:Here's array solution

To save
On key S pressed -> Array: Set value at 0 to Tilemap.AsJSON

To load
On key L pressed -> Tilemap: Set JSON string from Array.At(0)

and that's it.


Well, this definitively worked, but i have a new problem. My tilemap is 2800x2300 (yes, i know that's not a good idea) so when i try to save it, nw.js just closes.
B
7
S
2
G
1
Posts: 17
Reputation: 534

Post » Thu Apr 14, 2016 11:49 pm

Hi. I have a layout , which loads a tilemap tile by tile < copy those events to the next sheet
B
33
S
18
G
28
Posts: 2,455
Reputation: 20,874

Post » Fri Apr 15, 2016 11:59 am

99Instances2Go wrote:Hi. I have a layout , which loads a tilemap tile by tile < copy those events to the next sheet

That's the first thing i did, and it worked. But it takes a lot of time, and i want to separate the loading layout and the gameplay mechanics. Isn't it possible to save as json a really huge array or tilemap?
B
7
S
2
G
1
Posts: 17
Reputation: 534

Post » Fri Apr 15, 2016 12:16 pm

How big?
When I'm going between layouts (main map <-> sub maps) On leaving the layout I'm saving to a Dictionary:
- Dictionary with all my variables
- Array with player characters infos
- Array with Inventory state
- Array with NPCs
- Array with NPCs that can be respawned
- Array with keys used in game
- 6 tilemaps - 4 different tilemap objects, each max 1920x1920 in size on layout

and then on loading next layout I'm loading everything back from that dictionary - that is really 1 huge dictionary. And it takes max 3 seconds to save and load on my old Samsung Galaxy S3 mobile, on PC it's instant.

So I don't know how big stuff you must have to tak a lot of time to save/load.
ImageImageImageImage
B
157
S
64
G
41
Posts: 2,590
Reputation: 34,640

Post » Fri Apr 15, 2016 5:41 pm

shinkan wrote:How big?
When I'm going between layouts (main map <-> sub maps) On leaving the layout I'm saving to a Dictionary:
- Dictionary with all my variables
- Array with player characters infos
- Array with Inventory state
- Array with NPCs
- Array with NPCs that can be respawned
- Array with keys used in game
- 6 tilemaps - 4 different tilemap objects, each max 1920x1920 in size on layout

and then on loading next layout I'm loading everything back from that dictionary - that is really 1 huge dictionary. And it takes max 3 seconds to save and load on my old Samsung Galaxy S3 mobile, on PC it's instant.

So I don't know how big stuff you must have to tak a lot of time to save/load.


2800x2300 tiles, 16 pixels for tile... 44800 x 36800. I guess that must be the reason of the crash.
B
7
S
2
G
1
Posts: 17
Reputation: 534

Post » Sun Apr 17, 2016 5:44 am

Why not add in a loading screen that could be playable until it loads I missed the old interactive loading screen maybe you can do that so that it isnt a boring wait.
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests