Player create levels and save [SOLVED]

0 favourites
  • 6 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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.

  • 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.

  • 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?

  • Use System -> Save ("yourfilename") to save the levels.. then when you need to load them, System -> Load ("yourfilename")

  • 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?

    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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Dalal and procrastinator.

    It's working very well for the puzzle.

    Thank you so very much.

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