按鍵「按」我如下執行動畫:CCAnimate laggy僅在第一次
//create sprite
animatedSprite = [[CCSprite alloc] initWithFile:@"transparentPixel.png" rect:CGRectMake(0, 0, 218, 218)];
SET_POS(animatedSprite, 167, 51);
[self addChild:animatedSprite z:5000];
//animate sprite
[animatedSprite runAction:[CCAnimate actionWithAnimation:[[CCAnimationCache sharedAnimationCache] animationByName:@"skill1use"]]];
//run cleanup fnktion
[animatedSprite performSelector:@selector(removeFromParentAndCleanup:) withObject:[NSNumber numberWithBool:YES] afterDelay:3];
[animatedSprite release];
以前我裝了框搭配:
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:[CCDirector sharedDirector].contentScaleFactor>[email protected]"[email protected]":@"skill_01_ani.plist"];
[[CCAnimationCache sharedAnimationCache] addAnimation:[CCAnimation animationWithSpriteSequence:[CCDirector sharedDirector].contentScaleFactor>[email protected]"skill_01_ani%[email protected]":@"skill_01_ani%04d.png" numFrames:34 delay:1/24.0] name:@"skill1use"];
然而,動畫運行後順利得多第一次,它第一次需要一段時間,直到它開始。我是否預載了動畫?有沒有辦法讓動畫第一次順利運行?
UPDATE
如果我設置下面的運行速度很快第一次預覽:
CCSprite *animatedSprite = [[CCSprite alloc] initWithFile:@"transparentPixel.png" rect:CGRectMake(0, 0, 218, 218)];
[self addChild:animatedSprite z:5000];
[animatedSprite runAction:[CCAnimate actionWithAnimation:[[CCAnimationCache sharedAnimationCache] animationByName:@"skill1use"]]];
[animatedSprite performSelector:@selector(removeFromParentAndCleanup:) withObject:[NSNumber numberWithBool:YES] afterDelay:3];
[animatedSprite release];
既然是一樣的運行動畫。不過,這隻適用於我實際顯示動畫(使用addChild和所有內容)
我對使用contentScaleFactor確定@ 2x文件加載感到畏懼。你爲什麼不使用cocos2d的native -hd文件擴展名? – LearnCocos2D
它比重命名所有文件更容易;) – Daniel
不認爲它真的更容易。收拾您的所有文件與zwoptex或texturepacker如果我預裝你將有隻有在所有的藝術 – Morion