我创建了一个 CCAnimation,如下所示。我尝试将延迟降低到 0.05f 以下,但动画现在无法完成!它只有 8 帧。我不知道我是否做错了什么。起初我认为这是内存泄漏,我正在丢失操作,所以我将它分配给一个强大的属性来测试它,并且仍然这样做了。我不确定延迟如何导致我的动画无法完成。我在模拟器中以每秒 60 帧的速度运行。
使用狗头人 2.0.4
任何人都可以帮忙吗?
else if([model currentState] == PROCESSING_FIRST_ACTION)
{
CCDirector* director = [CCDirector sharedDirector]; // process model
//Get the top left corner of the screen
int screen_height = director.screenSizeAsPoint.y;
int screen_width = director.screenSizeAsPoint.x;
id attacker = [model attacker];
id attackChoice = [attacker getRegisteredAttack];
CCAction* attack = [model.resourceManager animation: @"simple-attack-frame"];
CCSprite * attackSprite = [model.resourceManager sprite: @"simple-attack-frame-01"];
attackSprite.position = ccp(screen_width - rxa(80), screen_height - rya(80));
attackSprite.tag = 5;
self.action = attack;
CCNode * check = [self getChildByTag:5];
if(check == nil)
{
[self addChild: attackSprite];
[attackSprite runAction:attack];
}
}
resource manager:
-(id)animation: (NSString*)_resource
{
NSMutableArray *frames = [NSMutableArray array];
for(int i = 1; i <= 8; ++i)
{
[frames addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:@"%@-0%d", _resource, i]]];
}
CCAnimation *animation = [CCAnimation animationWithSpriteFrames: frames delay:1/60];
CCAction * action = [CCAnimate actionWithAnimation: animation];
return action;
}