Particle system looks different on iOS 6 and ios7

放肆的年华 提交于 2019-12-12 02:27:13

问题


I have a couple of particle systems on my app that I checked originally on an iPad 3 with ios7. The particles looked and behaved like I expected them, but when I test on an iPad2 with ios6. The particles are displaced up and are smaller. I have a subclass for the particles. Here's the code for one of my particle systems. I was wandering if the CGREctMake is positioning the particle in a different area on a non retina display, but that doesn't happen when I position other things on the display.

Code to call the particles.

- (void)ShowSteamEffect
{
    //Create view for Steam particle effect.
    CGRect SteamFrame = CGRectMake(790, 380, 100, 100);
    //Show Steam effect
    ShowSteam = [[SteamEffect alloc]initWithFrame:SteamFrame];
    ShowSteam.hidden = NO;
    [self.view insertSubview:ShowSteam aboveSubview:imgComputerLights];

}

Steam subclass.

#import "SteamEffect.h"

@implementation SteamEffect

{
    CAEmitterLayer* SteamEmitter;
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        SteamEmitter = (CAEmitterLayer*) self.layer;
        //SteamEmitter.emitterPosition= CGPointMake(0, 0);
        //SteamEmitter.emitterSize = CGSizeMake(10,10);
        CAEmitterCell* Steam = [CAEmitterCell emitterCell];
        Steam.birthRate = 50;
        Steam.spin = .6;
        Steam.lifetime = 1.7;
        Steam.alphaRange = 0.2;
        Steam.alphaSpeed = 0.2;
        Steam.contents = (id)[[UIImage imageNamed:@"Steam1.png"]CGImage];
        Steam.velocity = 30;
        Steam.velocityRange = 50;
        Steam.emissionLongitude = -60;
        Steam.emissionRange = M_1_PI;
        Steam.scale = .2;
        Steam.scaleSpeed = .5;
        Steam.yAcceleration = -200;

        SteamEmitter.renderMode =  kCAEmitterLayerBackToFront;
        SteamEmitter.emitterShape = kCAEmitterLayerCircle;
        SteamEmitter.emitterCells = @[Steam];

}
    return self;
}

-(void)didMoveToSuperview
{

    [super didMoveToSuperview];
    if (self.superview==nil) return;

    [self performSelector:@selector(disableEmitterCell) withObject:nil afterDelay:0.5];
}

-(void)disableEmitterCell
{ 
    [SteamEmitter setValue:@0 forKeyPath:@"birthRate"];
}

+ (Class) layerClass
{
    //tell UIView to use the CAEmitterLayer root class
    return [CAEmitterLayer class];
}

- (void) setEmitterPosition:(CGPoint)pos
{
    SteamEmitter.emitterPosition = pos;
}

- (void) toggleOn:(bool)on
{
    //SteamEmitter.birthRate = on? 300 : 0;
}

来源:https://stackoverflow.com/questions/22521154/particle-system-looks-different-on-ios-6-and-ios7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!