How do I make a collectible disappear once you take it

Get help using Construct 2

Post » Mon Jan 26, 2015 11:52 am

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!
B
4
Posts: 4
Reputation: 208

Post » Mon Jan 26, 2015 12:41 pm

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.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Mon Jan 26, 2015 1:04 pm

Somebody wrote: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
B
21
S
9
Posts: 298
Reputation: 2,967

Post » Mon Jan 26, 2015 6:41 pm

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!
B
4
Posts: 4
Reputation: 208

Post » Tue Jan 27, 2015 1:38 am

albtol wrote: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....
B
21
S
9
Posts: 298
Reputation: 2,967

Post » Tue Jan 27, 2015 1:12 pm

Ribis wrote:
albtol wrote: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 :)
B
4
Posts: 4
Reputation: 208


Return to How do I....?

Who is online

Users browsing this forum: ramyaswetha, Yahoo [Bot] and 7 guests