I encountered a weird issue a week or two ago in my defense game.
Originally I was loading images, creating sprites, etc at the beginning of each state of the program and stopping animations, clearing animation frames, stopping sprite tweens, deleting sprites, images etc at the end of each state. By state I mean Title Screen, Gameplay, GameOver, etc.
For some weird reason I started getting a "program stopped working" when moving from Gameplay back to the Title Screen. Well not so much started but more that I started doing thorough testing of navigating around from state to state where previously I was focused on developing & playing through the game focused on general testing & gameplay balancing.
Anyway through tracing I tracked it down to failing on DeleteAllImages() api call. No error message or anything only Windows itself telling me the program stopped working. I then manually unloaded every image and tracked it down to deleting specific subimages or if that worked (sometimes it did) then the error occurred while deleting the atlas image itself.
I then decided to just restructure everything and load all images at the start of the program and keep them in memory to the end. When the player exits the game I then do all of the clean-up and again the same error occurs same thing always while either using DeleteAllImages() or DeleteImage().
It's been incredibly frustrating. Finally I tried to just not even use DeleteImage() or DeleteAllImages() and in this case the program exits cleanly with no."programmed stopped working" error encountered.
So my question is does AppGameKit clean-up when the program ends? If so then I will just not even try to free the images myself since using DeleteImage or DeleteAllImages does not work for a few images for some completely unknown to me reason.
I even tried explicitly looping through all tweens from 1 to 999999 and if exists if playing stop it and then delete it and then looping through all sprites from 1 to 999999 checking if sprite exists if so set shader to 0, check if sprite is playing if so stop it checking if sprite animation frame count > 0 if so clear all frames and finally delete the sprite. Then sync a couple times to be sure chsnges are applied and then finally looping 1 to 999999 check if image i exists if so delete it.... and still on the deleteimage line "DefenseGame.exe has stopped working".
Yet if I do not try to clean-up with DeleteImages the program exits fine no errors. I don't get it at all. But as long as it is really freeing the images from memory then I will just leave it alone.