How do I trigger 'On app closed'?

  • Hi everyone,

    I'm publishing my C3 games on Android and I need a trigger for the moment in which the user chooses to close the app. In this moment, I want to save the game before closing.

    I'm aware of the Browser plugin's feature 'On back button', but the documentation says it's limited to certain devices, which is to unreliable for me.

    Is there any way to trigger on this condition?

  • Use google translate French -> English:

    Tu ne peux pas mettre de condition " A l'application fermée ..."

    Car si l'application est fermée alors aucune action n'est possible.

    Il faut que tu mettes tes actions de sauvegarde sur les conditions qui ferment ton application.

    Exemple:

    Si bouton_quitter est appuyé alors:

    - save

    - close app

    :) C3 lis les actions dans l'ordre donc il faut juste que tu fasse l'action de sauvegarde avant la fermeture de l'application, c'est tout :) J'espère t'avoir aidé ;)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • i.e.

    You can not put a condition "At the application closed ..."

    Because if the application is closed then no action is possible.

    You have to put your backup actions on the conditions that close your application.

    Example:

    If bouton_quitter is pressed then:

    - save

    - close app

    :) C3 read the actions in the order so you just have to do the backup action before closing the application, that's all :) I hope you helped;)

  • Thanks for the reply,

    yes, that is what I tried in the first place. Sadly, the documentation states the following:

    On back button

    Triggered when the user presses the device's 'Back' button. Note not all devices have this button (e.g. iOS devices only have a 'Home' button) and not all platforms support this trigger.

    That being sad, the way of triggering 'On back button' is quite unreliable.

  • Your best bet is probably to either write to local storage every time you need to make a savable change to data if you're making a stateful game, otherwise just auto save pretty often if you're using the system save action.

  • You don't need Close action for IOS. Just use it for Android.

    stackoverflow.com/a/14335936

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