0

我正在尝试从精灵表创建动画精灵,为此我正在运行以下命令:

NSMutableArray *bunsenAnimFrames = [NSMutableArray array];
    for(int i = 1; i <= 74; ++i) {
        [bunsenAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"15_%i.png", i]]];
    }

    for (int j = 1; j <= 74; ++j) {
        [bunsenAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"15_1.png"]]];
    }

    for (int k = 75; k <= 148; ++k) {
        [bunsenAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"15_%i.png",k]]];
    }

    for (int l = 1; l <= 74; ++l) {
        [bunsenAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"15_1.png"]]];
    }

    NSLog(@"bunsenAnimFrames is %@", bunsenAnimFrames );

    CCAnimation *bunsenAnimationAnimation = [CCAnimation animationWithSpriteFrames:bunsenAnimFrames delay:1/25];

    bunsens = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:bunsenAnimationAnimation]];

然后稍后在使用一组平铺精灵填充舞台时,我运行:

else if (blockValue == 2 || blockValue == 3 || blockValue == 4 || blockValue == 5) {
                bunsen = [CCSprite spriteWithSpriteFrameName:@"15_1.png"];

                if (blockValue == 2) {
                    bunsen.rotation = 90;
                }
                else if (blockValue == 3) {
                    bunsen.rotation = 180;
                }
                else if (blockValue == 4) {
                    bunsen.rotation = 270;
                }
                float tileY = screenSize.height-((countery*startData4)+startData4/2+77.5)/2;
                float tileX = ((counterx*startData4)+startData4/2+5)/2;

                bunsen.position = ccp(tileX,tileY);

                [bunsenAnimation addChild:bunsen];
                [bunsen runAction:bunsens];


            }

这在添加本生精灵(在头文件中声明为精灵)时效果很好,但是在调用[bunsen runAction:bunsens];精灵时没有任何反应,有什么原因吗?

4

1 回答 1

0

我为此找到的解决方案没有使用 CCAnimation 延迟中的一小部分......奇怪!因为我认为延迟值可以是任何浮点数!

于 2012-10-30T21:59:24.657 回答