How do I preset data to a file?

Get help using Construct 2

Post » Fri Dec 09, 2016 10:38 pm

I have a pattern that is made up of objects.
The game will have different preset patterns and the player will be able to change between pattern1, pattern2, etc.. with a push of a button.

Each object in the pattern has an X and Y value.
Each pattern will have between 9-27 objects stored in it.
So far I only have 1 pattern planned. I will be adding patterns as the game is more developed.

I don't think I can preset data into an array.
Should I store all the patterns in one file or would it be better if every pattern had it's own file to save memory usage?

I know vaguely of JSON and AJAX.

I just need to be pointed in a direction.
How am I able to preset the patterns?


Should I just create a Function for each pattern?
It seems like it may be similar. It isn't read unless called upon.
It would seemingly only increase the amount of events per tick a small bit and the download size.
B
65
S
37
G
13
Posts: 240
Reputation: 12,703

Post » Mon Dec 12, 2016 5:39 pm

I didn't understand what you actually mean with the pattern, but maybe you can just make a pattern editor which saves your pattern in the array.
Then you can export the array as a JSON string and put that in a project file. You can load the project file later with the AJAX Plugin.
I hope I could help! :)
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Mon Dec 12, 2016 7:37 pm

I meant I have a pattern of organized objects and each objects has two values to store.
There will be more than one pattern...

Pattern 1
x1,y1
x2,y2
x3,y3
x4,y4
x5,y5

Pattern 2
x1,y1
x2,y2
x3,y3
x4,y4
x5,y5

Each x and y would have it's own value.
Thanks I will look into that.
B
65
S
37
G
13
Posts: 240
Reputation: 12,703

Post » Fri Dec 16, 2016 7:27 pm

How do I export array to Json?

It seems like I can open a Json file using a browser, but I'm not sure how to export an Array.

Do I need another software?
B
65
S
37
G
13
Posts: 240
Reputation: 12,703


Return to How do I....?

Who is online

Users browsing this forum: bclikesyou, kalibark2 and 32 guests