Permanently destroy non-global objects
Hello all.
I am moving the player active object between 2 frames but I find that when I destroy objects in Frame 1, move to Frame 2 then back to Frame 1 again, the objects have re-appeared.
I can sort of see why, since the frame is started "afresh" each time it is visited, but is there a way to permanently destroy active objects in a game so that they only get created when you start a new instance of the game?
(I tried "global objects" but this doesn't seem to do the job).
Re: Permanently destroy non-global objects
If you are doing multiple frames, you should use some kind of an array to store all the data across frames. Try either array or ini object.
Re: Permanently destroy non-global objects
each time a frame is loaded, information from previous frames in 'forgotten'. You need to code a system to store information across frames. For example, if at the start of your frame you spread a value throughout an alterable value lets call it "Index" for your set of monsters
Then using an INI object for your game, you instance it for each save game slot, recording into the INI file the "Index" of every monster as you destroy it. For example, your code might read:
+Collision between Monster and Bullet
=Destroy Monster
=Write value 1 to INI file at Group:"LevelName" Index:"Monster"+str$(Index("Monster"))
then add some code at the start of each level of yours that reads from the ini file and deletes the objects:
+Start of Frame
=Spread Value 0 across Index("Monster")
=Start fast loop "KillStuff" for numObjects("Monster") number of times
+On fast loop "KillStuff"
+Index("Monster") = loopIndex("KillStuff")
+Get Value at INI at Group:"LevelName", Index:"Monster"+str$(LoopIndex("KillStuff")) == 1
=Destroy Monster
Re: Permanently destroy non-global objects
Thanks both, I will try that tomorrow, my brain is fried at the moment and I need sleep!
Re: Permanently destroy non-global objects
You can also use Global Values. These are unlimited.
Set to 1 for being destroyed. It will carry over all the frames and even sub-applications.
Marv
Re: Permanently destroy non-global objects
Gets to be a problem if you have a lot of objects to store though :)
Re: Permanently destroy non-global objects
Yes, there could be 500+ enemies spread over the entire game :)
Will look into the other method, thanks for the pointers.