Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
So im working in a open world type game (might crash windows) i think i may have created a better save load system It works like this (it only works for wanting to save colected idems, killed enemys, ect) Each Enemy is given a digit in a string of binary the of enemys long (10) alive enemys are 0 dead enemys are 1 0000000000 say we kill enemy 4 the var changes by adding 1x10 to the 3 power (3rd because the enemy's digit position -1) 0000001000 and so on until we want to save 1101011001 when we load we do this At First Drawing > Load Var :Enemy's > Do Something later : 5 >Set / Change a Var: Enemy's > Divide By 1x10 to the power of x. >Do Something Later :5> If Var has value do something: if Enemy is greater than 0.9 > delete scene node enemy 10 > Set /Change Var : Enemy Add 1x10 to the power of x Else: > Set /Change Var : Enemy Add 1x10 to the power of x Repeat from the beginind without the load var and change the first do something later to 10 the next to 20 and so on (x = first digits position in string right to left - 1) Could someone test this? |
||||
|
this is good but the problem is that if you have a lot of enemy's then you have to check every digit for it but you can make it but coppercube will lag a bit |
||||
|
@Zoo, so you are back. Glad to have you here. |
||||
|
That's crap. You will never be able to debug that if something goes wrong. Serialize to json and save to file. Read file back, deserialize use to restore state. That way you can also store more information, position, hitpoints and so on, not just boolean values. If you don't want people to understand encode it after serialization, store salt in variable set by default action, no one will ever find it. |
||||
|
Serialize to json is a nice solution or slightly easier you can use standard ccbWriteFileContent API : I use tonnes of arrays actually and you can easily save them to data or binary file format: var data1 = invMe.toString(); ccbWriteFileContent('data/save/invMe.bin', data1); When loading back (ccbReadFileContent) and using numbers in your code you will have to convert back into number format though as everything is string or text format by default. |
|