box2d

Box2d:negative value return from GetLinearVelocity();

When I use the following, sometimes I get a negative value in mmVelik.x and mVelik.y. Can anyone explain why?? b2Vec2 mVelik = ballBody->GetLinearVelocity(); ...

Change direction of a moving object....(pure physic question)

Hi, This is a pure physic question but i don't know why it doesn't work....i have a moving object.i get the value of vcos(theta) and vsin(theta)...from this i calculate the velocity and angle of motion.....also i know another point (x,y) and want to direct the object to this point.I think i need to apply a certain force(force must hav...

Box2D and sonic-like physics for platformer

I'm working on a platformer for the iPhone that is using Box2D and cocos2D. I'm trying to figure out a way to create similar behavior for my controlled character as is found in the Sonic the Hedgehog games, but maintain use of the Box2D physics library as I want projectiles and some level objects to behave according to realistic physics...

Game Objects setup in cocos2d + box2d

I am having a design issue, this may be due to the fact that i don't fully understand cocos2d and box2d yet. I want to create game objects that have a CCSprite(image data) and a b2Body(physics), Would i be right to make an encapsulating object that contains both? if i did this this would enable me to make changes to the CCSprite OR ...

box2d collision detection

Hi everyone Im using box2d in my game and i have a problem I need to determinate collision between two objects but only if they are touched with one exact side. For instance bottom of one object collided with top of another object. Could you give a pice of advice how can i do it? ...

Position of the vertex in Box2d

Hi How can i get position of the vertex in box2d ...

Box2d Calculating Trajectory

I'm trying to make physics bodies generated at a random position with a random velocity hit a target. I gleaned and slightly modified this code from the web that was using chipmunk to run in Box2d + (CGPoint) calculateShotForTarget:(CGPoint)target from:(CGPoint) launchPos with:(float) velocity { float xp = target.x - launchPos.x; ...

Box2d body moves faster after step is stopped and restarted in a pause [Android]

I am writing a game in android using Box2d physics engine in NDK. So physics is entirely in the native world but the drawing is still in Java world. In my game I have an update thread that steps the physics world and invalidates the canvas for redraw. So far so good. When the user wishes to pause the game I stop all the threads. Then us...

Box2d - Bike Game - Terrain

I'm using Box2d for a Bike Physics Game, Box2d lets you have fixtures that are convex polygons with 8 points or less, would anyone know of an easier way have a complicated concave terrain, other that just making a whole bunch of fixtures? Or is than the only way? Any ideas, pointers, suggestions... Thanks in advance! (any language is OK...

Why use Float.floatToIntBits() in Java float comparisons?

In JBox2d, there exists the following code for Vec2.equals(): @Override public boolean equals(Object obj) { //automatically generated by Eclipse if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Vec2 other = (Vec2) obj; if (Float.float...

Moving a player with Box2D

What is the proper way of moving a player in Box2D setting Player->ApplyForce() kind of feels like it lacks flexibility and control. What other ways might there be to do this? Thanks ...

Objects that defy gravity but collide with others in Box2D. How?

Hello, newbie to iPhone game development and Box2D here. I'm developing a game in which I can move (drag) otherwise stationary objects that can collide with other objects. How do I make these objects stationary in a Box2D world with gravity while maintaining their ability to collide with dynamic bodies? One random thought is to exert ...

jBox2d android drawing dynamic bodies

Hi, I started off with the tutorial here and added drawing code for a view (covering the entire screen). The scene appears static and not dynamic even though I'm calling world.step(,). How does one make the scene dynamic and is my drawing the right implementation or is there a better way (using jBox2d functions)? private class Physics...

JBox2D reference manual

Where do i find reference manual of JBox2D ? I was using fisica which inherits JBox2D. There is reference manual of fisica but can't find reference manual of JBox2D ...

cocos2d:Interchange Sprite

Hi, I use the following to to interchange only the position of 2 sprite. CCSprite *sprite1 = (CCSprite*)[self getChildByTag:tagOfFirstSprite]; CCSprite *sprite2 = (CCSprite*)[self getChildByTag:tagOfSecondSprite]; CGPoint SpritePosition1 = [sprite1 position]; CGPoint SpritePosition2 = [sprite2 position]; [spri...

Body moves too fast after ApplyLinearImpulse()

I have top-down game for iPhone (no gravity) and I'm using Cocos2d and Box2d. I try to move a bullet by this code: // 'targetPosition' is a point of touch b2Vec2 touchInWorld = b2Vec2(targetPosition.x/PTM_RATIO, targetPosition.y/PTM_RATIO); b2Vec2 direction = b2Vec2(touchInWorld.x - ballBodyDef.position.x, touchInWorld.y - ballBody...

How can I remove objects in Box2d after collision, but with a delay?

I am using cocos2d and box2d in my iPhone game. When two balls hit each other, I get a notification though the ContactListener and I have a reference to both bodies. I can destroy both of them, but I would like to do it with a delay. So, two balls hit each other, they bounce off and then after a second disappear. ...

How to make a moving object "stick" to a stationary object in box2D

Hello, I have been experimenting with the box2D sample project within cocos2D for the iPhone and am wondering if box2D is the appropriate engine to use to make a moving object "stick" to a stationary object when the moving object is finished moving in a certain direction. Here is a simplification of what I am trying to achieve: I hav...

Box2D b2World in class

So I've got: class bc_Game { public: //blah private: b2World world; }; bc_Game::bc_Game() { //blah, defining variables used world = b2World(gravity, sleep); } Now, I just get error: no matching function for call to 'b2World::b2World()' note: candidates are: b2World::b2World(const b2Vec2&, bool) note: b2World::b2Worl...

How to compile Box2D for C# with SWIG?

I'm trying to compile Box2D for use in C# with SWIG. I've created this Box2D.i file, %module Box2D %{ #include "Box2D/Box2D.h" %} %include "Box2D/Box2D.h" Which I placed one level up from the Box2D.h file file, and "compiled" it with, swig.exe -csharp -c++ -includeall -ignoremissing -outdir SWIG Box2d.i This gives me all the .cs ...