First version

This commit is contained in:
2022-04-11 17:17:23 +03:00
committed by GitHub
parent 45a79eed20
commit fde1669b60
29 changed files with 1434 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
#import "AppDelegate.h"
#import "GameScene.h"
@implementation SKScene (Unarchive)
+ (instancetype)unarchiveFromFile:(NSString *)file {
/* Retrieve scene file path from the application bundle */
NSString *nodePath = [[NSBundle mainBundle] pathForResource:file ofType:@"sks"];
/* Unarchive the file to an SKScene object */
NSData *data = [NSData dataWithContentsOfFile:nodePath
options:NSDataReadingMappedIfSafe
error:nil];
NSKeyedUnarchiver *arch = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
[arch setClass:self forClassName:@"SKScene"];
SKScene *scene = [arch decodeObjectForKey:NSKeyedArchiveRootObjectKey];
[arch finishDecoding];
return scene;
}
@end
@implementation AppDelegate
@synthesize window = _window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
GameScene *scene = [GameScene unarchiveFromFile:@"GameScene"];
/* Set the scale mode to scale to fit the window */
scene.scaleMode = SKSceneScaleModeAspectFit;
[self.skView presentScene:scene];
/* Sprite Kit applies additional optimizations to improve rendering performance */
self.skView.ignoresSiblingOrder = YES;
self.skView.showsFPS = YES;
self.skView.showsNodeCount = YES;
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
return YES;
}
@end