Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- import SpriteKit
- class War: SKScene {
- static var sharedWar = War(size.size)
- ...
- }
- - (void)save {
- [[NSUserDefaults standardUserDefaults] setObject:@{@"x" : @(self.x), @"y" : @(self.y)} forKey:@"WarKey"];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- - (void)load {
- NSDictionary *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"WarKey"];
- if (data == nil) {
- self.x = DEFAULT_X;
- self.y = DEFAULT_Y;
- } else {
- self.x = [data[@"x"] intValue];
- self.y = [data[@"y"] intValue];
- }
- }
Add Comment
Please, Sign In to add comment