按键“按”我如下执行动画: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