2013-02-12 3 views
4

나는 CAEmitterCell로 놀고 있지만 대부분의 효과는 불꽃 같은 매우 빠른 효과입니다. 하지만 여기서 볼 수있는 것처럼 느린 "별"효과를 원합니다. www.findyourwaytooz.comCAEmitterCell - 느린 별 또는 조명 효과

CAEmitterCell로 어떻게 할 수 있습니까?

당신을 :) 감사

+0

나는 이것을 실제로 해냈다. 나에게 시간을 좀주세요. GitHub에 게시 할 수 있습니다. – jhilgert00

답변

5

나는 이미 터에 대해 다음 설정을 사용하는 프로젝트를 가지고 있고, 그것은 꽤 정확하게 당신이 무슨 뜻 무슨 생각을 모방 : 나는 GitHub의에 샘플 프로젝트를 업로드

//set ref to the layer 
starsEmitter = (CAEmitterLayer*)self.layer; //2 

//configure the emitter layer 
starsEmitter.emitterPosition = CGPointMake(160, 240); 
starsEmitter.emitterSize = CGSizeMake(self.superview.bounds.size.width,self.superview.bounds.size.height); 
NSLog(@"width = %f, height = %f", starsEmitter.emitterSize.width, starsEmitter.emitterSize.height); 
starsEmitter.renderMode = kCAEmitterLayerPoints; 
starsEmitter.emitterShape = kCAEmitterLayerRectangle; 
starsEmitter.emitterMode = kCAEmitterLayerUnordered; 

CAEmitterCell* stars = [CAEmitterCell emitterCell]; 
stars.birthRate = 0; 
stars.lifetime = 10; 
stars.lifetimeRange = 0.5; 
stars.color = [[UIColor colorWithRed:255 green:255 blue:255 alpha:0] CGColor]; 
stars.contents = (id)[[UIImage imageNamed:@"particle.png"] CGImage]; 
stars.velocityRange = 500; 
stars.emissionRange = 360; 
stars.scale = 0.2; 
stars.scaleRange = 0.1; 
stars.alphaRange = 0.3; 
stars.alphaSpeed = 0.5;  
[stars setName:@"stars"]; 

//add the cell to the layer and we're done 
starsEmitter.emitterCells = [NSArray arrayWithObject:stars]; 

: SimpleCAEmitterLayer

+2

멋진 데모. "particle.png"가 번들에 복사되지 않았습니다. 즉, 누락되었습니다. 새로운 그래픽으로 교체하십시오. –

+0

감사합니다. skinnyTOD, 동기화 될지 확인합니다. :) – jhilgert00

+0

대단히 감사합니다. 그걸로 놀기 위해 나를 위해 :) 당신은 내 하루를 만들었습니다 – cuSoon2013

관련 문제