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

  • SEARCH
  • Home
  • 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 8096539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:28:58+00:00 2026-06-05T21:28:58+00:00

fresh to objC and cocos2d :) i’m following learn cocos2d game development with iOS5,

  • 0

fresh to objC and cocos2d 🙂

i’m following “learn cocos2d game development with iOS5”, in chapter4, there is a “DoodleDrop” game.

define some variable in GameScene.h like this

@interface GameScene : CCLayer
{
    CCSprite *player;
    CGPoint playerVelocity;
    CCArray *spiders;
    CGSize screenSize;
    int dropedSpidersCount;
    float duration;
}
    + (CCScene *)scene;
@end

in GameScene.m the init method looks like this

- (id)init
{
    if (self = [super init]) {
        duration = 4.0;
        [self createPlayer]; 
        [self createSpiders]; // spiders were inited here.
        [self resetSpiders];
        [self schedule:@selector(chooseSpider:) interval:0.7];
    }
    return self;
}

while in chooseSpider, i cannot access spiders, xcode broke

enter image description here

in other methods, spiders or duration just behave normally, why does this happens?


gist code added

https://gist.github.com/2940466

  • 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-05T21:29:01+00:00Added an answer on June 5, 2026 at 9:29 pm

    After inspecting your code, I suggest you to try this fix:

    - (void)createSpiders
    {
    CCSprite *tempSpider = [CCSprite spriteWithFile:@"spider.png"];
    CGSize spiderSize = [tempSpider texture].contentSize;
    int spiderCount = screenSize.width / spiderSize.width;
    spiders = [[CCArray arrayWithCapacity:spiderCount] retain];
    
    for (int i = 0; i < spiderCount; i++) {
        CCSprite *spider = [CCSprite spriteWithFile:@"spider.png"];
        [self addChild:spider];
        [spiders addObject:spider];
    }
    }
    

    where the only difference is in the line:

    spiders = [[CCArray arrayWithCapacity:spiderCount] retain];
    

    Indeed, if you do not retain you spiders object, it will be autoreleased at the next run loop iteration.

    OLD ANSWER:

    Without seeing more code it is not possible to say exactly what is happening, but it seems that in the interval between creating the spiders and the actual execution of chooseSpiders, your spiders array gets deallocated.

    As a quick try, I would suggest adding:

    [spiders retain];
    

    before calling

        [self schedule:@selector(chooseSpider:) interval:0.7];
    

    and see wether the crash keeps happening.

    if you provide more code, it could be possible to help you further.

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

Sidebar

Related Questions

I need a fresh temporary directory to do some work in a shell script.
I have a fresh install of the latest Eclipse Helios for Java EE development
We are starting a fresh J2ME application development. (example: in .NET Composite Application Block
I recently installed a fresh development setup on my laptop and now notice that
On a fresh Debian system (Squeeze/Sid) I have installed the following packages using apt-get:
Fresh Ubuntu 10.04 install: I'm having some trouble getting my gem install process to
I'm fresh blackberry application developer. I want to create some new and creative blackberry
I have a fresh install of phpmyadmin on my vpn server. It has some
I'm fresh to F#, but I really want to learn it. I know Python,
In a fresh install of 3.6 I see the following types of rights available

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.