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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:51:22+00:00 2026-05-18T08:51:22+00:00

Hi all im working on an ipad app using cocos2d objective c and box2d.

  • 0

Hi all
im working on an ipad app using cocos2d objective c and box2d. my question is in relation to box2d and collisions with curves. basically i have circles within a larger circle arena. the smaller circles collide with each other fine but i want to know how to make them collide with the edges of the larger arena circle correctly so that they dont leave the arena and bounce back in. any ideas on how to approach this problem would be great
cheers

  • 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-18T08:51:23+00:00Added an answer on May 18, 2026 at 8:51 am

    ok i got it working but im not sure if its the correct way to do it

    int sides = 50;
    
        float x_coordPREV=([Arena contentSize].width/2)*cos(0.0);
        float y_coordPREV=([Arena contentSize].width/2)*sin(0.0);
        x_coordPREV += Arena.position.x;
        y_coordPREV += Arena.position.y;
    
        b2BodyDef arenaBodyDef;
        arenaBodyDef.position.Set(0,0);
        b2Body *arenaBody = _world->CreateBody(&arenaBodyDef);
        b2PolygonShape arenaBox;
        b2FixtureDef arenaShapeDef;
        arenaShapeDef.shape = &arenaBox;
    
        for(float angle=0.0f;angle<(2*M_PI);angle+=(2*M_PI)/sides){
            float x_coord=([Arena contentSize].width/2-10)*cos(angle);
            float y_coord=([Arena contentSize].width/2-10)*sin(angle);
            x_coord += Arena.position.x;
            y_coord += Arena.position.y;
            arenaBox.SetAsEdge(b2Vec2(x_coordPREV/PTM_RATIO,y_coordPREV/PTM_RATIO),b2Vec2( x_coord/PTM_RATIO,y_coord/PTM_RATIO ));
            arenaBody->CreateFixture(&arenaShapeDef);
            x_coordPREV = x_coord;
            y_coordPREV = y_coord;
        }
    

    this creates a circle out of 50 sides and appears to be doing what i want. if anyone has a better way please let me know
    ty

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

Sidebar

Related Questions

No related questions found

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.