0

私のアプリは、具体的にはURLからいくつかのリソースを取得し、それらをディレクトリ.pvr.cczに保存します。Documents

NSString *documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
...
[responseObject writeToFile:[documentsDirectoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", <file_name>, @"pvr.ccz"]] options:NSAtomicWrite error:nil];

その後、 と を使用してスプライトを作成し.plistます.pvr.ccz.pngプロジェクトに既に存在するプロパティ リストで指定されたイメージのリスト。

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"<property_list_name>.plist"];
CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:[NSString stringWithFormat:@"<file_name>.png"]];

これは、次のように警告されます。-[CCFileUtils fullPathFromRelativePath:resolutionType:] : cocos2d: Warning: File not found: <file_name>.pvr.ccz

Cocos2D で特定のフォルダに保存された URL からリソースを検索できるようにする方法はありますか? または、URL からリソースを Cocos2D が見つけられる場所に保存する方法はありますか?

4

1 に答える 1

1

coco's へのフル パスを指定すると、そこに表示されると思います。したがって

NSString*fqn = [documentsDirectoryPath stringByAppendingPathComponent@"<property_list_name>.plist"];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:fqn];

これを試したことはありませんが、うまくいくはずです。

EDIT : .plist がプロジェクトにあると仮定しますが、.pvr.ccz はドキュメント ディクショナリにあります。さらに、テクスチャの名前が「downloaded-hd.pvr.ccz」であると仮定すると、プロジェクトでデバイスの HD が有効になり、次の例でファイルが見つかるはずです。

NSString*textureFileName=@"downloaded-hd.pvr.ccz";
NSString*fqn = 
    [documentsDirectoryPath stringByAppendingPathComponent:textureFileName];
[[CCSpriteFrameCache sharedSpriteFrameCache] 
    addSpriteFramesWithFile:@"<property_list_name>.plist"
            textureFileName:fqn];

-hd は静かに正しく処理されると思います。

于 2012-11-19T04:44:42.813 に答える