How do I Save One object as JSON or Array Data?

Get help using Construct 2

Post » Sun Nov 29, 2015 10:08 am

I am having a great difficulty figuring out how to load zones of objects (like large streaming engine games that allow travel over great distances). Sans switching game engines, I dont see many examples about doing something like this, especially because of localstorage constraints perhaps...

How do I find the specific command for saving ONE OBJECT's data as a JSON file? Is it through arrays only? I can figure out how to build an object into an array I guess. Assigning strings and number values to be loaded from on the fly while in certain regions every amount of time I guess. Thats one way. Anyone know of other ways to approach this problem? I'm used to being able to literally disable objects in other engines and disable them or enter them dormant. In construct 2 this is just not possible. They must be destroyed completely and even then I hear theyre still in memory. So youre going to have to re-use objects or something....
B
5
S
1
Posts: 68
Reputation: 515

Post » Sun Nov 29, 2015 10:38 am

What do you mean by ONE OBJECT's data?
Which data would this be and how are you tracking this data right now?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Nov 29, 2015 10:51 am

i was planing to load up a array by putting all the data in the array on one line as json But i read a post @Ashley write state its no good to load a like this way it take up memory on make game take long to load
on start of layout array load on paste in the code simple
"{""c2array"":true,""size"":[200,111,1],""data"":[[[""NAME""],[""J""],[100]]]}"

she say it best to load it from a file so search the forum on how to use ajax. As a start for me i just forget about arrary
B
9
S
2
Posts: 66
Reputation: 717

Post » Sun Nov 29, 2015 10:52 am

hothead wrote:i was planing to load up a array by putting all the data in the array on one line as json But i read a post @Ashley write state its no good to load a like this way it take up memory on make game take long to load
on start of layout array load on paste in the code simple
"{""c2array"":true,""size"":[200,111,1],""data"":[[[""NAME""],[""J""],[100]]]}"

she say it best to load it from a file so search the for on how to use the ajax as a start for me i just forget about arrary


Ouch, I didnt know we arent supposed to use a ton of arrays for object management, are arrays the only things that can save object data as JSON?
B
5
S
1
Posts: 68
Reputation: 515

Post » Sun Nov 29, 2015 10:59 am

As this manual entry states, asjson is a common expresion..
Many objects have it..

https://www.scirra.com/manual/133/common-expressions

The sprite-object itself has an asjson expresion and load from json action, that's why I asked my previous question..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 03, 2015 6:27 am

I figured it out everyone thank you. I didnt realize that asJSON is a state string with numbers and letters.
B
5
S
1
Posts: 68
Reputation: 515


Return to How do I....?

Who is online

Users browsing this forum: RadiantRogue and 2 guests