我有一个改变纹理的精灵(基本上是不同的颜色)。我想要在30秒内不立即改变纹理。我怎样才能做到这一点?另外,我该如何重复这个过程?因此它应该保持蓝色30秒然后变为红色。然后再次重复该过程
sprite = [CCSprite spriteWithFile:@"blue.png"];
[sprite setTexture:[[CCTextureCache sharedTextureCache] addImage:@"red.png"] ];
答案 0 :(得分:1)
试试这个:
id delayTime1 = [CCDelayTime actionWithDuration:2.0f];
id calFun1 = [CCCallBlock actionWithBlock:^{
//HERE SET BLUE TEXTURE..
sprite.color = ccc3(0,255,0);
}];
id delayTime2 = [CCDelayTime actionWithDuration:2.0f];
id calFun2 = [CCCallBlock actionWithBlock:^{
//HERE SET RED TEXTURE..
sprite.color = ccc3(255,0,0);
}];
id sequece = [CCSequence actions:delayTime1, calFun1, delayTime2, calFun2, nil];
id repeate = [CCRepeatForever actionWithAction:sequece];
[sprite runAction:repeate];