Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 1de7b16b7b
Fetching contributors…

Cannot retrieve contributors at this time

file 103 lines (82 sloc) 3.018 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
//
// CBFAppreciationViewController.m
// BluesFest
//
// Created by Samuel Corder on 6/24/12.
//
//

#import "CBFAppreciationViewController.h"
#import <QuartzCore/QuartzCore.h>

@interface CBFAppreciationViewController ()
{
    UIStatusBarStyle lastStyle;
}
@end

@implementation CBFAppreciationViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor blackColor];
    CGRect viewBounds = self.view.layer.bounds;
    
    //Create the fire emitter layer
    fireEmitter = [CAEmitterLayer layer];
    fireEmitter.emitterMode = kCAEmitterLayerOutline;
    fireEmitter.emitterShape = kCAEmitterLayerLine;
    fireEmitter.renderMode = kCAEmitterLayerAdditive;
    fireEmitter.emitterPosition = CGPointMake(viewBounds.size.width/2.0, viewBounds.size.height - 50);
    fireEmitter.emitterSize = CGSizeMake(10, 10);

    CAEmitterCell *fire;
    fire = [self createFireCellColored:[UIColor colorWithRed:0.2 green:0.4 blue:0.8 alpha:.10]];
    
    UIImage *fireImage = [UIImage imageNamed:@"fire"];
    
    fire.contents = (id)fireImage.CGImage;
    
    //Name the cell so that it can be animated later using keypaths
    [fire setName:@"fire"];
    
    //Add the fire emitter cell to the fire emitter layer
    fireEmitter.emitterCells = [NSArray arrayWithObject:fire];
    
    [self.view.layer addSublayer:fireEmitter];
    
    [self setGasLevel:1.3];
    
    //[self.view setNeedsDisplay:YES];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (CAEmitterCell *)createFireCellColored:(UIColor *)color;
{
    //Create the fire emitter cell
    CAEmitterCell* fire = [CAEmitterCell emitterCell];
    fire.emissionLongitude = M_PI;
    fire.velocity = -80;
    fire.velocityRange = 30;
    fire.emissionRange = .6;
    fire.yAcceleration = -200;
    fire.scaleSpeed = 0.3;
    fire.color = color.CGColor;
    return fire;
}

- (void)setGasLevel:(float)gas
{
    //Update the fire properties
    [fireEmitter setValue:[NSNumber numberWithInt:(gas * 1000)] forKeyPath:@"emitterCells.fire.birthRate"];
    [fireEmitter setValue:[NSNumber numberWithFloat:gas] forKeyPath:@"emitterCells.fire.lifetime"];
    NSNumber *lifetimeRange = [NSNumber numberWithFloat:gas * .35];
    [fireEmitter setValue:lifetimeRange forKeyPath:@"emitterCells.fire.lifetimeRange"];
    fireEmitter.emitterSize = CGSizeMake(30 * gas, 0);
}


-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    lastStyle = [UIApplication sharedApplication].statusBarStyle;
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:lastStyle animated:YES];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
Something went wrong with that request. Please try again.