When I archive SKLabelNodes and SKShapeNodes (I have not tried SKSpriteNotes) no problem, but when I extract the sprites from the archive i get SKTexture: Error loading image resource: "Missing Resource.png".
Here is some example code that demonstrates the problem:
-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
/* Setup your scene here */
self.backgroundColor = [SKColor colorWithRed:0.15 green:0.15 blue:0.3 alpha:1.0];
SKLabelNode *const myLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"];
myLabel.text = @"Hello, World!";
myLabel.fontSize = 30;
myLabel.position = CGPointMake(CGRectGetMidX(self.frame),
CGRectGetMidY(self.frame));
// Archive
NSFileManager *const fm = [NSFileManager defaultManager];
NSURL *const dir = [fm URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0];
NSURL *const archive = [dir URLByAppendingPathComponent:@"example"];
[NSKeyedArchiver archiveRootObject:myLabel toFile:archive.path];
// Unarchive
SKLabelNode *const arLabel = [NSKeyedUnarchiver unarchiveObjectWithFile:archive.path];
myLabel.position = CGPointMake(CGRectGetMidX(self.frame) + 30,
CGRectGetMidY(self.frame) + 30);
[self addChild:myLabel];
[self addChild:arLabel];
}
return self;
}
Any idea what I am doing wrong?