Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8462933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:19:06+00:00 2026-06-10T14:19:06+00:00

So I have developed an app using CAEmitterLayer. Initially I made it to emit

  • 0

So I have developed an app using CAEmitterLayer. Initially I made it to emit automatically (when the app loads, it will start emitting the sparkles), it worked fine both in simulator and device.

Now, I changed it to emit when user taps on the screen. It works fine in simulator. On device, its not reacting. Please assist me in the right direction.

Initialized tap in -viewDidLoad

tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];

Assigned in -viewWillAppear

tap setNumberOfTapsRequired:1];
[self.view addGestureRecognizer:tap];

- (void) particles {

    if (!sparkling) {

        rootLayer = [CALayer layer];
        rootLayer.bounds = CGRectMake(0, 0, 320, 480);
        CGColorRef color = [[UIColor clearColor] CGColor];
        rootLayer.backgroundColor = color;
        CGColorRelease(color);

        const char* fileName = [[[NSBundle mainBundle] pathForResource:@"DazStarOutline" ofType:@"png"] UTF8String];
        CGDataProviderRef dataProvider = CGDataProviderCreateWithFilename(fileName);
        id img = (__bridge id)CGImageCreateWithPNGDataProvider(dataProvider, NULL, NO, kCGRenderingIntentDefault);

        const char* fileNameR = [[[NSBundle mainBundle] pathForResource:@"DazRing" ofType:@"png"] UTF8String];
        CGDataProviderRef dataProviderR = CGDataProviderCreateWithFilename(fileNameR);
        id imgR = (__bridge id)CGImageCreateWithPNGDataProvider(dataProviderR, NULL, NO, kCGRenderingIntentDefault);

        mortor = [CAEmitterLayer layer];
        mortor.emitterPosition = CGPointMake(320, 0);
        mortor.renderMode = kCAEmitterLayerAdditive;

        CAEmitterCell *rocket = [CAEmitterCell emitterCell];
        rocket.emissionLongitude = M_PI / 2;
        rocket.emissionLatitude = 0;
        rocket.lifetime = 2.0;
        rocket.birthRate = 1;
        rocket.velocity = 400;
        rocket.velocityRange = 100;
        rocket.yAcceleration = -250;
        rocket.emissionRange = M_PI / 4;
        color = [[UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.5] CGColor];
        rocket.color = color;
        CGColorRelease(color);
        rocket.redRange = 0.5;
        rocket.greenRange = 0.5;
        rocket.blueRange = 0.5;

        CAEmitterCell *spark = [CAEmitterCell emitterCell];
        spark.contents = img;
        spark.lifetime = 0.05;
        spark.yAcceleration = -250;
        spark.beginTime = 0.8;
        spark.scale = 0.4;
        spark.birthRate = 10;

        preSpark.emitterCells = [NSArray arrayWithObjects:spark, nil];
        rocket.emitterCells = [NSArray arrayWithObjects:flare, nil];
        mortor.emitterCells = [NSArray arrayWithObjects:rocket, nil];
        [rootLayer addSublayer:mortor];
        [self.view.layer addSublayer:rootLayer];

        sparkling = TRUE;
    }
}

Tap Gesture Method

- (void)handleSingleTap:(UIGestureRecognizer *)gestureRecognizer {

    [self particles];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:19:08+00:00Added an answer on June 10, 2026 at 2:19 pm

    So I downloaded your project. Two issues – one is that the CFRelease is not proper – you don’t own that color. But more important, if you take a color from a UIColor CGColor, you should really use the CG method to copy the color, then manage that resource. I know this gets complex, but when you mix CG and UI you will get complexity – you cannot avoid it.

    I took your project, converted to ARC, then also created strong ivars that hold the UIColors that you want to use (as CGColorRefs). You cannot create a tempt UIColor, ask it for its CGColorRef, then expect that color to be around when the UIColor goes away.

    The slightly modified project, it works great on the simulator and device (iPhone 4).

    [Note – really nice use of CAEmitter – pretty!!!]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed an Android app using Appcelerator Titanium. This app will create a
I have developed my app using core data. It works fine in the simulator.
I have developed a web app using a webservice. Everything works fine in the
I have developed a blackberry app, in which I am using Persistent Storage to
I have developed an app that in testing has worked fine but when it
I have developed an iPhone app using an iPhone 3G. How can I test
I have developed a simple DB-editing app using Xceed's excellent DataGrid for WPF (UX
I have an ios5 app developed using storyboards that currently displays a tab bar
I have developed an iPhone app using Monotouch and am about to do some
I have developed an app and have been using Monkey to test it. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.