ios - Re load UIImage after game restarts -
I have a game that uses the photo library, you take a picture from the library, and then on the next screen And photos are there you play this game, and after that when you have an option to start the game again, everything is working on this point when the problem starts again, The picture does not reload. I have searched for a solution completely, but I have not got anything to help me.
So basically I have a need of a game to save the picture so that the user can continue playing with that picture. After they start resume again. Does anyone have any idea how can I get it?
Note: If the photo decides to choose a different picture, then the photo can be overwritten, as long as the new picture is saved. > Thanks for your time
edit This is in my menu view controller then load the image for and my Resume button You can save data from and to reload it: Alternatively, you can store UIImage outside of your game data, so that you can load it the next time without hitting the file system.
- (minus) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {self.myImage = [information objectForKey: UIImagePickerControllerEditedImage]; [Self shotgun viewer unpowered: yes complete: zero]; [Self display CJU with identifier: @ "game" sender: self]; [Self defense]; } - (zero) save {NSDT * pngData = UIImagePNG report (myImage); NSArray * path = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, yes); NSString * documentsPath = [path objectAtIndex: 0]; // Get Docs Directory NSString * filePath = [Document Path StringBackCancyPantCompanyant: @ "Image Page"] ;; // Add file name [pngData writeToFile: filepath atom: yes]; // file type}
- (IBAction) Refresh TheGame {UIStoryboard * storyboard = self.storyboard; ViewController * svc = [storyboard institute Drishykantrolr Vithaidentifayr: @ "Jimel"]; SVC. Model Tronjisnstail = Umodl Tronsisnstail Cross Disilv [own current model Viaiuai controller SCC animated: YES]; [self-loading side image];} - (void) LoadSavedImage {NSArray * paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, Yes); NSString * documentsPath = [path objectAtIndex: 0]; // Get Docs Directory NSString * filePath = [Document Path StringBackCancyPantCompanyant: @ "Image Page"] ;; NSDTA * pngData = [NSData data content content file: filespath]; UIImage * image = [UIImage imageWithData: pngData]; [Copper set image: image]; }
when user selects the photo UIImage to file with a known file name, and just load it the next time the game restarts. To save a
UIImage to the file:
NSArray * path = NSSearchPathForDirectoriesInDomains (NSD Document Directory, NSUserDomainMask, Yes); NSString * filePath = [[Path ObjectEndIndex: 0] stringbapping pathcompany: @ "GameImage page"]; [UIImagePNG report (image) Write: Filepath atomically: Yes];
NSArray * path = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, Yes); NSString * filePath = [[Path ObjectEndIndex: 0] stringbapping pathcompany: @ "GameImage page"]; NSDTa * ImageData = [NSDTATA DataWithTransffiles: Phylax]; UIImage * img = [UIImage imageWithData: imageData];
Comments
Post a Comment