[解决]伙计们,我在Mac应用程序商店中找到了另一个名为Plist Extractor的工具,它可以帮助我做到这一点。非常感谢你们!
我在GitHub上找到了this project。它是一个实用程序来解压缩cocos2d引擎使用的cocos2D精灵表。尝试阅读和调试这个项目后,我找不到任何错误,但它没有按照我的预期工作。特别是,它始终从精灵帧生成空白图像并将其保存到磁盘。所以任何人都可以帮我调试一下。我还附上一张雪碧表供你们测试。
答案 0 :(得分:0)
尝试This SpriteSheetUnPacker使用精灵表。
答案 1 :(得分:0)
试试这个
#import "ExtractImagesFromTP.h"
[ExtractImagesFromTP createImagesFromTPPlist:@"sprite_sheet.plist"];
ExtractImagesFromTP Class
·H
@interface ExtractImagesFromTP : NSObject
+ (void)createImagesFromTPPlist:(NSString *)plist;
@end
的.m
@implementation ExtractImagesFromTP
+ (NSDictionary *)getAllFrameFromPlist:(NSString *)plistFile
{
NSString *path = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent: plistFile];
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:path];
return [dictionary objectForKey: @"frames"];
}
+ (void)createPngFromSprite:(CCSprite *)sprite fileName:(NSString *)fileName
{
sprite.position = ccpMult(ccpFromSize(sprite.contentSize), 0.5);
[CCDirector sharedDirector].nextDeltaTimeZero = YES;
CCRenderTexture* render = [CCRenderTexture renderTextureWithWidth:sprite.contentSize.width height:sprite.contentSize.height];
[render begin];
[sprite visit];
[render end];
NSLog(@"Texture Name: %@", fileName);
[render saveToFile:fileName format:CCRenderTextureImageFormatPNG];
}
+ (void)createImagesFromTPPlist:(NSString *)plist
{
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile: plist];
NSDictionary *frameNames = [self getAllFrameFromPlist: plist];
for (NSString *frameName in frameNames)
{
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:frameName];
CCSprite *sprite = [CCSprite spriteWithSpriteFrame: frame];
[self createPngFromSprite:sprite fileName:frameName];
}
}
@end