Player create levels and save [SOLVED]

Get help using Construct 2

Post » Sat Apr 04, 2015 12:31 am

Hello everybody.

Need some help / advice. I have a level of my game, where the player can move objects like a puzzle. What is the best way to save each position of objects, do not say its the "Save System" (because it freezes the screen).

I will be more accurate:
I wanted to create events to save the level modified by the player.
Example: After the player changes could save levels, they would be available in a menu, there the player could enter and change again.

I need ideas to make the system to save the changes.
Last edited by derikvlog on Sun Apr 05, 2015 1:38 am, edited 1 time in total.
B
17
S
1
Posts: 89
Reputation: 1,259

Post » Sat Apr 04, 2015 9:49 am

If you want to make your own save system, you'll probably need to look into Arrays.

Basically, for each puzzle object that you want to save, you'll need to store the object's name/identifier (e.g "Ball"), its x-position, and its y-position. For Each loops will be handy here. You'll want to go through each object, and push its data into the array. Once your array is filled with the correct data, you can save the array data as JSON (that's your "save"). Later, when it comes time to "load" the level, you can load that JSON into an array, then use the imported data to recreate the objects in their saved configuration, using the identifiers to figure out which type of object to create, and the X and Y positions to figure out where to place that object in the world.

That's the basic approach I would take, but there may be a simpler "built-in" approach I am not aware of. If you are not comfortable implementing this idea on your own, I would suggest posting the .capx here so people can help you.
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053

Post » Sat Apr 04, 2015 7:02 pm

Dalal wrote:If you want to make your own save system, you'll probably need to look into Arrays.

Basically, for each puzzle object that you want to save, you'll need to store the object's name/identifier (e.g "Ball"), its x-position, and its y-position. For Each loops will be handy here. You'll want to go through each object, and push its data into the array. Once your array is filled with the correct data, you can save the array data as JSON (that's your "save"). Later, when it comes time to "load" the level, you can load that JSON into an array, then use the imported data to recreate the objects in their saved configuration, using the identifiers to figure out which type of object to create, and the X and Y positions to figure out where to place that object in the world.

That's the basic approach I would take, but there may be a simpler "built-in" approach I am not aware of. If you are not comfortable implementing this idea on your own, I would suggest posting the .capx here so people can help you.


I get it, but I have several identical objects in the scene. The amount of scenarios would be pre-established.

Would have a way of following the player to create the level, I return to the menu without losing one layout?

Image
B
17
S
1
Posts: 89
Reputation: 1,259

Post » Sat Apr 04, 2015 7:36 pm

Use System -> Save ("yourfilename") to save the levels.. then when you need to load them, System -> Load ("yourfilename")
B
15
S
5
G
7
Posts: 876
Reputation: 5,650

Post » Sat Apr 04, 2015 7:48 pm

derikvlog wrote:I get it, but I have several identical objects in the scene. The amount of scenarios would be pre-established.

Would have a way of following the player to create the level, I return to the menu without losing one layout?

Image

If all your puzzle objects are identical, then it makes it even easier. The same concept applies. You want to get your data into an Array, and then save it as JSON text. In your case, you can use WebStorage and set a local value where the key = "Level [X]", and the value = [JSON data]. In the end, you'll have three local values saved, one for each level. When you want to load a given level: simply fetch the data using the respective key, load from JSON into an array, and then loop through the array to fetch the position values, and set your objects' positions accordingly.

Note that if you're not used to using Arrays, it might be worth getting some extra help. If you don't like this approach, I would explore the current built-in Save functionality that C2 provides (as @procrastinator mentioned), but I don't know much about it, and I believe you mentioned that the built-in Save does not work for you.
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053

Post » Sun Apr 05, 2015 1:37 am

Dalal and procrastinator.
It's working very well for the puzzle.

Thank you so very much.
B
17
S
1
Posts: 89
Reputation: 1,259


Return to How do I....?

Who is online

Users browsing this forum: rotacak and 7 guests