Particle system looks different on iOS 6 and ios7

2019-09-09 16:53发布

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;
}

0条回答
登录 后发表回答