I've been using SpriteKit for a while in iOS; now I'm developing an app for the Mac.
I've setup a texture atlas as usual:
- Enable texture atlas generation for both the Project and the Target (I started from the "Document Based Application" template, not "SpriteKit Game". It has different build settings).
- Drag all the individual texture image files into a folder,
- Rename the folder to "Something.atlas",
- Add the folder to the project,
- At runtime, create the atlas by name (i.e.,
[SKTextureAtlas atlasNamed:@"Something"];). - Obtain individual "textures" by name (i.e.,
[_atlas textureNamed:@"MyTexture"];) and createSKSpriteNodeinstances with them.
I am preloading the atlas asynchronously, but the completion handler never gets called (see comments):
_atlas = [SKTextureAtlas atlasNamed:@"Something"];
if (!_atlas) {
NSLog(@"Error: Failed to create atlas!");
// This line doesn't execute, so atlas is not nil.
}
[_atlas preloadWithCompletionHandler:^(void){
// This block doesn't get executed either,
// so atlas loading somehow fails...
NSLog(@"Atlas Loaded!");
[self createSprites];
}];
When I check the package contents of the build product (e.g., MyApp.app), in the resources subdirectory I can see the atlas folder ("Something.atlasc"), but it only contains a .plist file with no entries, and the image resources are nowhere to be found... So what gives?
selfinside the block isn't a good idea? - Nicolas Miari