Save Game [solved]

Discussion in 'How Can I...?' started by JSeeger6, May 8, 2020.

  1. JSeeger6

    JSeeger6 Avid Boxer

    Joined:
    Aug 29, 2018
    Messages:
    100
    Likes Received:
    12
    I'm working in BB3 and wondering if there is a "Settings.something" line of code to tell the game to save progress (level, current score, best score, etc.)? I want to do this when the character progresses to the next level.

    When debugging in Xcode, if you were to close the app using home button, a message shows up in the log saying the progress saved. However this "save" doesn't happen until the user closes the game which could be problematic if it crashes for example. Is there a way to custom save in BB3? Unfortunately, this is only something you can really see if it works when running from Xcode.

    Thanks!
     
    Last edited: May 11, 2020
  2. kwinchi

    kwinchi Boxer

    Joined:
    Jul 31, 2019
    Messages:
    32
    Likes Received:
    9
    you can use System.save() ; to manually save the settings class
     
    aminee and JSeeger6 like this.
  3. JSeeger6

    JSeeger6 Avid Boxer

    Joined:
    Aug 29, 2018
    Messages:
    100
    Likes Received:
    12
    THANK YOU SO MUCH!!!
     
  4. shahar.m192

    shahar.m192 Avid Boxer

    Joined:
    Oct 7, 2018
    Messages:
    204
    Likes Received:
    44
    where exactly I should put it?
     
  5. JSeeger6

    JSeeger6 Avid Boxer

    Joined:
    Aug 29, 2018
    Messages:
    100
    Likes Received:
    12
    You can put it wherever you want the game to save. I put mine in the an "init" function within the main character so every time the character progresses to the next level, the progress saves (in case of crashing, etc.)
     
  6. Haider Zaydoon

    Haider Zaydoon Boxer

    Joined:
    Aug 16, 2020
    Messages:
    6
    Likes Received:
    0
    I didn't quite understand how to use that code. So if I write System.save(); in the init() function of my character, will the game automatically save? and if that's the case, will the game auto save each frame or each new scene or each checkpoint?
    I'm currently working on a game and I want to introduce a "Start new game", "Continue where you left", and "Load saved file". Can you please help me with this?
     
  7. JSeeger6

    JSeeger6 Avid Boxer

    Joined:
    Aug 29, 2018
    Messages:
    100
    Likes Received:
    12
    If you put it in the init() function, then the game will save once when you load the UI that contains that code. For example, if you put the System.save() in a node that belongs to your character, then the game will save every time the character is loaded (so on the Game UI). You can put the code wherever you want though. For example if you only want your game to save when you collide with something, you can do that. The game will only save at each frame ONLY if you put it in an update() function. Otherwise it will only execute once.

    Is this idea for iOS?
     
  8. Haider Zaydoon

    Haider Zaydoon Boxer

    Joined:
    Aug 16, 2020
    Messages:
    6
    Likes Received:
    0
    Very well explained! Thank you very much!
    I'm trying to make a game and publish it on steam. It's a story-driven game, so the levels won't be infinite and the players will need the ability to save, load, and start new game.

    Any ideas on how I can make buttons in "UI" menu that will serve my purpose?
     
  9. JSeeger6

    JSeeger6 Avid Boxer

    Joined:
    Aug 29, 2018
    Messages:
    100
    Likes Received:
    12
    An idea might be to custom make your own button! So create a new asset in a UI screen, and add a "Touch" node and "State" node. When it's pressed, bring it to state 1 (where the art looks selected) and on 'release' connect that to state 2 (the normal state of the button). If it's released, also attach a script node to state 2 where in "Signal" write "if(value) System.save();" and that is your save node :)

    It's a little hard to tell you more about what to do having not looked at your game, but I think that could point you in a good direction?
     
  10. Haider Zaydoon

    Haider Zaydoon Boxer

    Joined:
    Aug 16, 2020
    Messages:
    6
    Likes Received:
    0
    I tried that but it didn't work. This is my checkpoint set up:

    BB3 Nodes.JPG

    And this is the save game script:

    BB3 Save Script.JPG

    Speaking of UI buttons. I once created a UI button in the main menu, then created a UI button in the character nodes and connected it to the save game script but it didn't work. The logger showed that the button wasn't even being pressed!
     
  11. bahaa

    bahaa Boxer

    Joined:
    Jul 20, 2020
    Messages:
    86
    Likes Received:
    3
    hello i have mad a game but i have a problem that every time i loss my player starts from beginning again i added a extra life option button that i learned from YouTube video's but the problem its starts from level 1 so how can i make my game load from last saved level and my levels are build on sinces not multiple worlds i have 15 science so 15 levels each since is a level so i want if my player dies for example on since 5 on the game over jump menu i have a option button to press and play from level 5 and not level 1 again please can you help me
    if you want give me your email and i can send you my project file
     

Share This Page