나는 CAEmitterCell
을 가지고 있으며 특정 색으로 설정했습니다. 문서에 this property is animatable이 있으며, 게임 내 다른 플레이어가 여러 색상을 사용하여 애니메이트하고 싶습니다. 플레이어는 처음부터 색상을 선택합니다.CAEmitterCell Color 속성에 애니메이션 적용
여기 내가 그것을 설정할 때 내 EmitterCell
입니다 :
//
// Emitter Cells
//
// 'New Emitter' cell configuration
newEmitter = [CAEmitterCell emitterCell];
newEmitter.scaleSpeed = 10;
newEmitter.lifetime = 2.481715;
newEmitter.velocity = 332.3636968085106;
newEmitter.contents = newemitterImg;
newEmitter.name = @"New Emitter";
newEmitter.color = [[UIColor colorWithRed:0.50 green:0.00 blue:1.00 alpha:1.00] CGColor];
newEmitter.scaleRange = 4.178236607142859;
newEmitter.lifetimeRange = 1.6;
newEmitter.greenRange = -2.775558e-17;
newEmitter.birthRate = 40;
newEmitter.emissionRange = -6.283185306666667;
newEmitter.scale = 0;
//
// Emitter Cell Chains
//
emitter.emitterCells = [NSArray arrayWithObjects:newEmitter, nil];
을 그리고 여기 그냥 두 개의 서로 다른 색상을 수신 거부,이 경우 색상 변경을 테스트하고있는 곳입니다 :
-(void)changeColor {
if (color == 0) {
color = 1;
NSLog(@"color = 1");
[UIView animateWithDuration:1.5 delay:0 options:0 animations:^{
newEmitter.color = [[UIColor colorWithRed:0.50 green:0.00 blue:1.00 alpha:1.00] CGColor];
} completion:^(BOOL finished) {[self performSelector:@selector(changeColor) withObject:nil afterDelay:2];}];
} else {
color = 0;
NSLog(@"color = 0");
[UIView animateWithDuration:1.5 delay:0 options:0 animations:^{
newEmitter.color = [[UIColor colorWithRed:1.00 green:0.50 blue:0.10 alpha:1.00] CGColor];
} completion:^(BOOL finished) {[self performSelector:@selector(changeColor) withObject:nil afterDelay:2];}];
}
}
을하지만, 이걸 실행할 때 색이 변하지 않습니다. "Animatable"의 성격을 오해 했습니까? 아니면 CAEmitterCell
의 경우 다르게 처리해야합니까?
어떻게 Y을 색깔을 바꾸시겠습니까? 코드를 변경하면 코드가 작동하지 않는 것 같습니다. – Bobby