How do I make a collectible disappear once you take it

  • Hi:

    I am working on a platform game with collectibles that once you obtain should not appear again in the levels. They have the "Persist" behaviour, so if you take them they will disappear during the game session. The problem is: if you close the app and you reopen it, the will appear again.

    I am trying to use the WebStorage, but no result yet.

    I would appreciate if you have any advice

    Thank you!

  • Quite likely you need a variable for the collectibles. Then you can place each one as usual, but add on startup - this collected >0 destroy specific collectible. Or an array if there are many. Then just save it and load it as needed.

  • Quite likely you need a variable for the collectibles. Then you can place each one as usual, but add on startup - this collected >0 destroy specific collectible. Or an array if there are many. Then just save it and load it as needed.

    yes, with an array will works perfect... if you have 30 objects, just save all variables in array... you can save a JSON string and reload when you need it

  • Hi:

    Thank you Somebody and Ribis so much!

    I tried with Arrays and JSON and worked. I now have some new bugs related to WebStorage but I can fix them.

    Thank you again!

  • Hi:

    Thank you Somebody and Ribis so much!

    I tried with Arrays and JSON and worked. I now have some new bugs related to WebStorage but I can fix them.

    Thank you again!

    You are welcome, but webstorage is not very good for save this kind of stuff....if the user clean the cache, he will lose everything....

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > Hi:

    >

    > Thank you Somebody and Ribis so much!

    >

    > I tried with Arrays and JSON and worked. I now have some new bugs related to WebStorage but I can fix them.

    >

    > Thank you again!

    >

    You are welcome, but webstorage is not very good for save this kind of stuff....if the user clean the cache, he will lose everything....

    Thanks. I am targeting Android, so as I understand I will avoid this problem. If not, what should I use to save data?

    By the way, just in case you know how to do it, is it possible to retrieve several numbers of an Array at the same time with an expression? That is, I can use Array.At(0), Array.At(1), Array.At(2)... But can I retrieve all the values between Array.At(0) and Array.At(100)

    Thank you in advance

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