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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:42:55+00:00 2026-06-14T07:42:55+00:00

I am using Box2D with Cocos2D in my app. So pretty much in my

  • 0

I am using Box2D with Cocos2D in my app. So pretty much in my app I make the bodies follow my CCSprites even though people recommend against it. Also I only use Box2D for collision detection so I just attach a body to my sprites and use a b2ContactListener and nothing else. Anyway this setup works for the most part except this little issue.

So my bodies follow my sprites like this in the game loop:

for(b2Body *b = world->GetBodyList(); b; b=b->GetNext()) {
        if (b->GetUserData() != NULL) {
            CCSprite *sprite = (CCSprite *)b->GetUserData();
                b2Vec2 b2Position = b2Vec2(sprite.position.x/PTM_RATIO, sprite.position.y/PTM_RATIO);
                float32 b2Angle = -1 * CC_DEGREES_TO_RADIANS(sprite.rotation);
                b->SetTransform(b2Position, b2Angle);
        }
    }

Also I create my b2World like this (if it makes any difference):

world = new b2World(b2Vec2(0.0f, 0.0f));
world->SetAllowSleeping(NO);
_contactListener = new MyContactListener();
world->SetContactListener(_contactListener); 

This issue is, whenever my CCSprites collide (technically my b2Bodys are colliding too), the b2Body on each CCSprite seems to move a bit as if a tiny force just hit it so they have a “recoil” if that makes sense. They move farther away from each other when the hit occurs even though no forces are involved.

Another example is when one of my bodies sits on top of another body, the body that is being stood on seems to tilt a bit when I am on the edge of it which is odd because I don’t tilt my sprites.

Lastly, my bodies seem to be a bit behind on where the sprite is at that exact moment and I am not sure if that is also related to this issue but anyway is there any reason why this would be happening? Is there any way to make it so the bodies are not affected by forces and are solely used for collisions?

Thanks!

  • 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-14T07:42:56+00:00Added an answer on June 14, 2026 at 7:42 am

    I believe that the bodies are triggering a collision response upon collision, which causes them to momentarily move apart a little, before snapping back into position when you force their b2transforms to sync with the sprite’s positions/angles in the next game tick.

    Since you are using Box2D purely for collision detection, did you set the isSensor property of your fixture definition to true?

    b2FixtureDef shapeDef;
    shapeDef.isSensor = true;
    

    By specially marking the fixture as a sensor, it will never physically collide with anything, but you will still be notified when an overlap of bodies occur, via the contact listener.

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

Sidebar

Related Questions

I'm developing an app using cocos2d and box2d phisycs. I whant to make my
I am developing an iPhone app using cocos2d and box2d.In this app i require
I'm using Box2D on my iPhone app using Cocos2D. I'm using mouse joint to
Hi all im working on an ipad app using cocos2d objective c and box2d.
I want to learn how to make levels using cocos2d and box2d (for iOS).
I'm using Cocos2D 1.0.1, and it doesn't get the latest Box2d. So, I would
I'm working on a platformer for the iPhone that is using Box2D and cocos2D.
I've encountered a weird problem about positioning bodies in cocos2d/box2d. If I set b2BodyDef
I am using Box2D with Cocos2D in my game. I am aware that Cocos2D
I am using box2d and cocos2d for my jump based game. I need to

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.