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 3279002
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:32:37+00:00 2026-05-17T19:32:37+00:00

I want update position of Particles for store this information I use NSMutableArray. I

  • 0

I want update position of Particles for store this information I use NSMutableArray. I want do update 1 time per 2 seconds for example. For this I try use this code.

//ParticlesLayer.h
@interface ParticlesLayer : CCLayer {
CCQuadParticleSystem *particle;
NSMutableArray *partilesCoordinates;
}

@property (assign, readwrite) NSMutableArray *partilesCoordinates;
-(void)partilesMove:(ccTime)dt;
-(void)particleInit;

//ParticlesLayer.m
@implementation ParticlesLayer

@synthesize partilesCoordinates;

-(id) init {
self = [super init];
    partilesCoordinates = [NSMutableArray arrayWithCapacity:5];
    [partilesCoordinates addObject: [NSValue valueWithCGPoint:ccp(67,152)]];
    [partilesCoordinates addObject: [NSValue valueWithCGPoint:ccp(140,147)]];
    [partilesCoordinates addObject: [NSValue valueWithCGPoint:ccp(198,100)]];
    [partilesCoordinates addObject: [NSValue valueWithCGPoint:ccp(261,126)]];
    [partilesCoordinates addObject: [NSValue valueWithCGPoint:ccp(364,135)]];
    // bla bla bla
    //...
    //bla bla bla
    [self schedule:@selector(partilesMove:) interval:2];
    return self;
} 

-(void)emittersMove:(ccTime)dt{
    NSMutableArray *newParticlesCoordinates = [NSMutableArray arrayWithCapacity:5];
    CGPoint newPoint;
    for (int i = 0; i < 5; ++i) {
        [self particleInit];
        NSLog(@"%@", [particlesCoordinates objectAtIndex:i]); // on this part of code i have problem
        particle.position = [[particlesCoordinates objectAtIndex:i] CGPointValue];
        [self addChild:emitter];
        newPoint = emitter.position;
        newPoint.x += 15;
        newPoint.y += 15;
        [newParticlesCoordinates addObject:[NSValue valueWithCGPoint:newPoint]];
    }
    [partilesCoordinates removeAllObjects];
    [partilesCoordinates newParticlesCoordinates];
    [newParticlesCoordinates removeAllObjects];
}

But when i run it on first calling function and reading from particlesCoordinates array i have console message : Program received signal: “EXC_BAD_ACCESS”. How I can make normal-working schedule?

  • 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-05-17T19:32:38+00:00Added an answer on May 17, 2026 at 7:32 pm

    [NSMutableArray arrayWithCapacity:5] returns an autoreleased instance, and that gets cleaned up some time after leaving the initializer. Now the pointer partilesCoordinates points to undefined memory. You need to do:

    partilesCoordinates = [[NSMutableArray arrayWithCapacity:5] retain];
    

    or

    partilesCoordinates = [[NSMutableArray alloc] initWithCapacity:5];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to update/upgrade the standard Leopard install of Sqlite3 to >3.5 to use
All I want is to update an ListViewItem's text whithout seeing any flickering. This
I'm using a TextItem in SmartGWT and I want to update the cursor position
I want to use a temp directory that will be unique to this build.
I want to update a list of storage devices as the user inserts USB
I want Windows Update to automatically download and install updates on my Vista machine,
I want to update two columns in a table. The value of the second
I have two lists of custom objects and want to update a field for
We're currently running a server on Compatibility mode 8 and I want to update
I want so send every week an update by email. But Im afraid that

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.