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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:55:25+00:00 2026-06-15T12:55:25+00:00

I create iOS app with Cocos2d v 1.0.1 and Box2d (cocos2d + box2d template).

  • 0

I create iOS app with Cocos2d v 1.0.1 and Box2d (cocos2d + box2d template).
On iPad my app works ok
On iPhone 4,4s ( ios versions 5.0.1 , 6.0 , not tested on other iPhones/firmwares) I got EXC_BAD_ACCESS at beginning of my game (after short time of playing) .

myActor.position = CGPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO  );

I analyzed state of b and Box2d world, and it looks like the bodies list of world is corrupted.
Pointer to b contains b2PolygonShape, not a b2Body (I see that in Variables View in Xcode).
Sometimes (also only on iPhones), my game begins to behave unexpectedly.
I set breakpoints in my update method and realized that Box2d world’s body list contatins only one body (but at previous update world contains many bodies, and visually they are on screen on current update).

I checked code of my game, and cannot find the error, or reason of such behavior.
I tried to use Analyze feature of Xcode, change Box2d version, and some other things.
I couldn’t solve this problem for now.
What approaches should I use to debug this crash?
What can I do to research and solve it?

  • 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-15T12:55:26+00:00Added an answer on June 15, 2026 at 12:55 pm

    I have found the error by excluding parts of Box2d-related code from my app.
    In following code

        CCDelayTime *destroyDelay = [CCDelayTime actionWithDuration:0.001];
        CCCallBlock *destroyBlock = [CCCallBlock actionWithBlock:^{
            b2Body * b = (b2Body *)[bodyVal pointerValue];
            b->SetUserData(NULL);
            [self world]->DestroyBody(b);
        }];
        [self runAction: [CCSequence actions:destroyDelay,destroyBlock, nil]];
    

    pointer b, stored in NSValue, may not be valid when CCCallblock is executed, and this leads to memory errors.

    I replaced this code with

    NSValue *bodyVal = [NSValue valueWithPointer: body ];
    [self.bodiesThatHeroCollidedWith addObject: bodyVal ];
    

    and then in my update: method I cleans the self.bodiesThatHeroCollidedWith array:

    for (NSValue *body in self.bodiesThatHeroCollidedWith) {
        b2Body *b = (b2Body *)[body pointerValue];
        b->SetUserData( NULL );
        world->DestroyBody( b );
    }
    [self.bodiesThatHeroCollidedWith removeAllObjects];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an iOS (iPhone specific) app where users have to authenticate
Can I create iphone app (IOS) using web's languages ( HTML - CSS -
I'm working on this ios app project with cocos2d, and I need to create
I want to create an iOS app that contains a uiimageview and a button
I'm looking to create a simple iOS app that displays the current water level
I want to create a simple desktop admin application for an IOS app that
I'm using Sudzc to create my WebService proxy classes for an iOS app. The
I've been trying very very hard to create a simple simple iOS app which
i'm trying to create a photo viewer like the Apple Photos app in iOS.
I want to create an app for iPod Touch 2nd generation (iOS 4.2.1). For

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.