在动画(SKAction)iOS期间更改值

时间:2014-08-18 08:45:10

标签: ios animation sprite-kit skaction

我有如下动画。

坐下动画:

SKTexture *sit1 = [SKTexture textureWithImageNamed:@"sit_1_blur.png"];
SKTexture *sit2 = [SKTexture textureWithImageNamed:@"sit_2_blur.png"];
SKTexture *sit3 = [SKTexture textureWithImageNamed:@"sit_3_blur.png"];
SKTexture *sit4 = [SKTexture textureWithImageNamed:@"sit_4_blur.png"];
SKTexture *sit5 = [SKTexture textureWithImageNamed:@"sit_5_blur.png"];

NSArray *sitPng   = @[sit1,sit2,sit3];
NSArray *drinkPng = @[sit3,sit4,sit5];

sitAnimation   = [SKAction animateWithTextures:sitPng timePerFrame:0.2];
drinkAnimation = [SKAction animateWithTextures:drinkPng timePerFrame:1];


-(void) takeSit{
    [self runAction:sitAnimation completion:^{
        [self startDrink];
    }];
}

如何在startDrink动画期间每秒更改一次值?像这样:

someValue +=0.2;

1 个答案:

答案 0 :(得分:0)

你需要在你的startDrink动画中有这个(我假设startDrink是在某处定义的另一个动作),

+ (SKAction *)customActionWithDuration:(NSTimeInterval)seconds actionBlock:(void (^)(SKNode *node, CGFloat elapsedTime))block;

测量通过的时间并更新someValue + = 0.2;相应

希望这有帮助。