我的项目涉及IOS 12+ iPhone,并且我正在使用发射器在屏幕上跟随用户的手指(使用平移手势识别器)。使用以下代码时,我已经注意到,玩游戏时屏幕会变热,并且使用该应用的次数越多,电池消耗的速度往往比平时更快。
有没有特别需要配备一个能在屏幕上跟随手指的火源,同时又具有电池友好型解决方案?
//set ref to the layer
cursorEmiter = [CAEmitterLayer layer];
//configure the emitter layer
cursorEmiter.emitterPosition = CGPointMake(50, 50);
cursorEmiter.emitterSize = CGSizeMake(5, 5);
CAEmitterCell* fire = [CAEmitterCell emitterCell];
fire.birthRate = 1000; // The number of emitted objects created every second. Animatable
fire.lifetime = 0.6; // The lifetime of the cell, in seconds. Animatable
fire.lifetimeRange = 0.5;
fire.color = [[UIColor colorWithRed:1.0 green:0.4 blue:0.2 alpha:0.3]
CGColor];
fire.contents = (id)[[UIImage imageNamed:@"PopCornSmall.png"] CGImage];
fire.velocity = 10; // The initial velocity of the cell. Animatable
fire.velocityRange = 20;
fire.scaleSpeed = 0.3;
fire.spin = 0.5;
cursorEmiter.renderMode = kCAEmitterLayerAdditive;
[fire setName:@"fire"];
//add the cell to the layer and we're done
cursorEmiter.emitterCells = [NSArray arrayWithObject:fire];
emiterNotAdded = false;
[(CAEmitterLayer *)self.layer addSublayer: cursorEmiter];