How do I save/load all properties of all sprite using a file

0 favourites
  • 5 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • I'm doing a 2d tool program based on sprites.

    I'm looking how to save all the sprites properties like: Name, X/y position, instance values, opacity,effect parameters,etc... in a file and after in a new runing load that file that create all the sprites with their properties to regenerate the same composition.

    I saw the sprites have a AsJSON and "set from JSON" but, how i tell the code how to create the sprites and how many sprites and in which one add what properties ¿?

    I search in the forum and i saw this one:

    Changing the SaveState to text instead a global number save/loads the properties of the object, but i have no idea that how do the rest.

    I guess, at least for save, create a family called "sprites" and using an Array plugin and then: For each sprite save their JSON state in a X. so i will have stored in each X(x1,x2,x3) the properties of each sprite. But how i save all that in a .txt o .JSON file and how load all that after to recreate the same composition? :S

    I tried another way using the System:save but each file gets near 80mb and saving is a bit slow, works but is not an option .

    So, how i do the .json thing?

  • Well, at least now i can save and load the family sprite states using json and arrays in the runtime.

    https://dl.dropboxusercontent.com/u/659 ... tate2.capx

    Now i guess is export the Array.JSON state. SO in a new running i will load the arrays and a for each to any sprite.

    But if i create more sprites, and if i run the app without any sprite, how i tell the program he have to create a sprite of X type and set their properties?

  • Well, you can save & load the sprite states on runtime.

    https://dl.dropboxusercontent.com/u/659 ... tate4.capx

    You can Press Circle or Square to create them and drag anywhere and works in the same app.

    Works the export button of Array.AsJSON

    So the unique problem still is create the objects and add their properties of the Array.asJSON. And well discover how open a file and get the text instead of put the direcction by default on import.

    Still nothing how to solve that?

  • matriax

    So you want to create objects using properties saved in .json file, right?

    Seems as we do running into similar issue in our projects. You've made a bigger progress tho. Well done!

    I'll take my time to inspect your work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When you load just re-create the objects from the array. The only problem is while saving can be done with a family, you need to create the individual sprites instead of creating the family.

    You can look here for something similar:

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