Questions tagged [box2d-iphone]

Box2D is a physics engine created by Erin Catto. This tag is similar to the box2d tag in that it is more specifically aimed at iOS development.

Box2D is a physics engine that is particularly popular among Cocos2D developers when developing a game for iOS devices. It is fairly fast and easy to use. More information can be found on its official website:

Box2D.org

For more information on Cocos2D (iOS) see:

Cocos2D-iPhone.org

410 questions
2
votes
1 answer

cocos2d and box2d: camera rotation

i have a similar situation to this Question. I want to keep the camera with the player in the center and the rotation of the player. But i'm using box2d so i can't rotate the environment and keep the player static. how can i do this with cocos2d? i…
thomasguenzel
  • 670
  • 7
  • 25
2
votes
0 answers

how to move circle in screen game

Possible Duplicate: Drag and drop UIViews with Box2d (iOS) create circle at bottom of screen if I touch down on circle,it will go on to top of screen and if I touch up,it falls down to bottom of screen.how can i create this type of game? Anybody…
Mrugen
  • 75
  • 4
2
votes
1 answer

issues creating a weld joint within contact listener class

I have set a contact listener that creates a weld joint when contact is established between two bodies. When the bodies touch I keep getting a SIGABRT pointing to the line b2Assert(IsLocked() == false); in the method b2Joint*…
Fannie
  • 21
  • 4
2
votes
5 answers

world->DestroyJoint(mouseJoint) on TouchesEnded : EXC_BAD_ACCESS

I have multiple sprites with physics bodies. User is moving one sprites at a time. A mouse joint is created to support the movement. Using Cocos2d V2.0 The mouse joint is initialized in the ccTouchesBegan after a QueryAABB(&callback, aabb) reports…
2
votes
1 answer

how to destroy a weld joint

I have searched extensively and haven't been able to find any guidelines or posts on destroying a weldJoint. How do I destroy the weldJoint between bodyA and bodyB? I created my weldJoint in the following way. weldJointDef.Initialize(bodyA,…
nullity
  • 23
  • 3
2
votes
1 answer

Why does using weld joints make my Box2D program slow?

I'm trying to implement weld joints for my box2d bodies: for(pos = _contactListener->_contacts.begin(); pos != _contactListener->_contacts.end(); ++pos) { MyContact contact = *pos; b2Body *bodyA = contact.fixtureA->GetBody(); …
my_name
  • 31
  • 5
2
votes
2 answers

how to change the group index of a body dynamically in box2d

I am new to box2d. I have started a new game in box2d and created 5 dynamic bodies in the world. Initially I need to prevent collision between them. so i set group index of all bodies negative. After touching a body i want to allow the collision…
Anusha Kottiyal
  • 3,855
  • 3
  • 28
  • 45
2
votes
1 answer

Relation between dimensions of a body and pixels in box2d iphone

Could anyone tell me about the relation between the dimensions of a body and number of pixels(in box2d). How many pixels contributes to one meter length? To be more specific, I'm using the below line of code in my program polygon_body.SetAsBox(1,…
jjpp
  • 1,298
  • 1
  • 15
  • 31
2
votes
2 answers

How to smoothly rotate a character according to the slope it is walking onto/standing on?

I need to rotate a character sprite according to the scope of the platform he (a rectangle) is standing or walking on. I have achieved the effect by rotating it according to the slope of the platform he is standing on. But there are two…
dz902
  • 4,782
  • 38
  • 41
2
votes
1 answer

Box2D debug test

I have a problem with Box2d. I created an object (circle) in the center of the screen that rotates to see if I set Box2d well, following the tutorial that I found on internet. The problem is that the circle is created, but I can't rotate despite I…
IlNero
  • 103
  • 1
  • 6
1
vote
2 answers

How to convert CCSprite to CCTexture2d

I am making an iPhone app using cocos2d and I have a CCSprite and I need to convert it to a CCTexture2d so I can put it into box2d. Here is the code I have so far, It crashes with a runtime error... //Set up sprite // Use batch node.…
King Popsicle
  • 465
  • 5
  • 17
1
vote
1 answer

How to convert bezier curve to box2d object?

I am drawing line using bezier curve and i need to convert that bezier curve into box2d object. Which object can i use in box2d? any suggestions?
Chandan Shetty SP
  • 5,087
  • 6
  • 42
  • 63
1
vote
1 answer

box2d accelerometer how to make it work

I'm trying to make the box2d accelerometer work, I have a car sprite and want it to move left and right, when the iPhone is tilted. Here is the code for the sprite: - (void)spawnCar { car = [CCSprite…
sahil
  • 141
  • 1
  • 9
1
vote
1 answer

How to temporally make bodies in box2d act like sensors (let another bodies go through them)

I know I can make b2Body sensor by setting special flag in b2BodyDef. But what I need is to temporally turn body into sensor, and then turn it back to not-sensor again. So I need a switch that will let another bodies to go through this body. Thank…
Dennis Krut
  • 423
  • 1
  • 6
  • 11
1
vote
1 answer

Simple collision detection in cocos2d box2d..nothing happens on collision

I'm trying to figure out how to do this, I have a sprite called 'player' and sprites called 'rock' I'm trying to detect collision between both sprites..... but nothing happens on collision! heres what i have done: -(void)addRock { rock = [CCSprite…