Guest User

Untitled

a guest
Oct 25th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import Foundation
  2. import SpriteKit
  3.  
  4. class War: SKScene {
  5.  
  6. static var sharedWar = War(size.size)
  7. ...
  8.  
  9. }
  10.  
  11. - (void)save {
  12. [[NSUserDefaults standardUserDefaults] setObject:@{@"x" : @(self.x), @"y" : @(self.y)} forKey:@"WarKey"];
  13. [[NSUserDefaults standardUserDefaults] synchronize];
  14. }
  15.  
  16. - (void)load {
  17. NSDictionary *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"WarKey"];
  18. if (data == nil) {
  19. self.x = DEFAULT_X;
  20. self.y = DEFAULT_Y;
  21. } else {
  22. self.x = [data[@"x"] intValue];
  23. self.y = [data[@"y"] intValue];
  24. }
  25. }
Add Comment
Please, Sign In to add comment