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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:19:36+00:00 2026-05-19T09:19:36+00:00

I have a method which returns a bool value, with several exit points. However,

  • 0

I have a method which returns a bool value, with several exit points.
However, it does not seem to work correctly, so I would like to set an automatic breakpoint to see when it returns a YES value, so I can check all the variables and calculations in the debugger.
I would like to stop the debugger whenever a YES value is returned.

I have a similar smart breakpoint set for objc_exception_throw, so I know it’s possible, I am just not sure how.


(In case it helps anyone, the way you can set the exception breakpoint: in the Breakpoints window (Run -> Show -> Breakpoints) enter objc_exception_throw as “Breakpoint”, and libobjc.A.dylib as “Location”)

EDIT: the specific code I would like to use it for:

- (BOOL)collisionOccured {
    // Assumption: helicopter is of square shape (collision calculated by radius), walls are rectangles
    // This approach is based on the solution seen here: http://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection/402010#402010

    float helicopterImageWidth = [helicopter texture].contentSize.width;
    float wallImageWidth = [[walls lastObject] texture].contentSize.width;
    float wallImageHeight = [[walls lastObject] texture].contentSize.height;
    float helicopterCollisionRadius = helicopterImageWidth * 0.4f;

    CGPoint helicopterPosition = helicopter.position;


    int numWalls = [walls count];
    for (int i = 0; i < numWalls; i++) {
        CCSprite *wall = [walls objectAtIndex:i];

        if ([wall numberOfRunningActions] == 0) {
            // The wall is not moving, we can skip checking it.
            continue;
        }

        CGPoint wallPosition = wall.position;

        float helicopterDistanceX = abs(helicopterPosition.x - wallPosition.x - wallImageWidth/2);
        float helicopterDistanceY = abs(helicopterPosition.y - wallPosition.y - wallImageHeight/2);

        if (helicopterDistanceX > (wallImageWidth/2 + helicopterCollisionRadius)) { return NO; }
        if (helicopterDistanceY > (wallImageHeight/2 + helicopterCollisionRadius)) { return NO; }

        if (helicopterDistanceX <= (wallImageWidth/2)) { return YES; }
        if (helicopterDistanceY <= (wallImageHeight/2)) { return YES; }

        float cornerDistance_sq = powf((helicopterDistanceX - wallImageWidth/2), 2) + 
                                powf((helicopterDistanceY - wallImageHeight/2), 2);

        return (cornerDistance_sq <= powf(helicopterCollisionRadius, 2));
    }

    // this should not occur
    return NO;
}

This method is called via

- (void)update:(ccTime)delta {
    if ([self collisionOccured]) {
        NSLog(@"A collision occured");
    }
}

The problem is that the update method takes delta (time passed) as argument, so I can’t check what’s happening frame by frame — whenever I continue the execution, I am presented with a different scene.

(I am using cocos2d in the code)

  • 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-19T09:19:36+00:00Added an answer on May 19, 2026 at 9:19 am

    You can set conditional breakpoints. With a slight tweak to update:

    - (void)update:(ccTime)delta {
         BOOL collided = [self collisionOccured];
         if (collided) {
            NSLog(@"A collision occured");
        }
    }
    

    you can set a breakpoint as normal after the BOOL‘s assignment (i.e. on the if line), then right-click on the blue breakpoint arrow and select “Show Message Bubble”, and add collided as the Condition. The extra variable should get optimized away in Release build mode.

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

Sidebar

Related Questions

I have a Java method which returns an array of doubles. I would then
I have a method which never returns a null object. I want to make
I have a method in .NET (C#) which returns string[][] . When using RegAsm
I have a C# method which accepts a Predicate<Foo> and returns a list of
In an actionscript function (method) I have access to arguments.caller which returns a Function
I have a method which is given the parameter bool sortAscending. Now I want
If I have a method that returns a BOOL , how do I cast
I have a method which takes params object[] such as: void Foo(params object[] items)
I have a method which should be executed in an exclusive fashion. Basically, it's
I have an method which save files to the internet, it works but just

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.