開発中のゲームで問題に直面しています。私はいくつかのアニメーションを持っていますが、私の問題は、それらは適切に動作しますが、初めて読み込まれるときに遅延が発生することです. 私はそれを解決する方法がわかりません。CCAnimationCache に関するすべてのドキュメントを読み、フォーラムを読みましたが、成功しませんでした。私はまだ同じ問題を抱えています。アニメーションは機能しますが、最初にそれらのいずれかが読み込まれると、遅延が発生します。それを手伝ってもらえますか?私もこのサイトを読みました: http://www.johnwordsworth.com/2011/07/loading-cocos2d-sprite-frame-animations-from-plist-files/そして彼らはプリロードについて話しますが、私の結果は同じです。
最初にアニメーションをキャッシュし、キャッシュにあるように見えますが、結果が常に望ましいものではなく、アニメーションの 1 つを初めてロードするたびにこの遅延が発生します。
仕様に従って CCAnimationCache を使用してすべてのアニメーションをプリロードする関数をコーディングしましたが、機能しないか、間違っている可能性があります。ここに私が作ったいくつかのコードがあります:
for(int element = 0; element < 3; element++){
for(int pos = 0; pos < 3; pos++){
CCAnimation *auxAnimation = nil;
animation = getAnimationInformationWithElement(element, pos);
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:[NSString stringWithFormat:@"%@.plist",animation.animationFileHeader]];
for(int i = 0; i <= animation.numberOfFrames; i++) {
if(i<=9)auxFileName = [animation.animationPNGFileName stringByAppendingString:@"0000"];
else auxFileName = [animation.animationPNGFileName stringByAppendingString:@"000"];
[elementsAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"%@%d.png",auxFileName,i]]];
}
auxAnimation = [CCAnimation elementsAnimFrames];
[animationsToBeSaved elementsAnimFrames];
elementsAnimFrames = [[[NSMutableArray alloc] init] autorelease];
[[CCAnimationCache sharedAnimationCache] addAnimation:auxAnimation name:[NSString stringWithFormat:@"animation_%d_%d",element,pos]];
}
}
何か案は?