box2d

calculate box2d impulse for a certain angle of impact

别说谁变了你拦得住时间么 提交于 2019-12-01 09:53:33
问题 I have a ball (a dynamic body in the shape of a circle) that acts on a surface (trampoline) in the conditions of a gravity force. When the ball impacts the trampoline (drawn in the picture from point A to B) I would like to apply an impulse (normal to the trampoline surface) to the ball. The problem is that right now i use: b2Vec2 impulse = b2Vec2(0, [self fullMass]*[GameMaster sharedInstance].usrTrampolineForce); b2Vec2 impulsePoint = _body->GetWorldPoint(b2Vec2(0/PTM_RATIO, -1.0/PTM_RATIO))

Rotate a Sprite on a bezier path with touch - Cocos2D/Box2D

自闭症网瘾萝莉.ら 提交于 2019-12-01 08:51:15
I have an arrow that I rotate with touch. I was wondering if it was possible to rotate the arrow on a curved line? I've done some research and I think it is called a bezier path? Is it even possible to rotate a sprite on a bezier path using this code and if so how would I even incorporate it? UITouch *touch = [touches anyObject]; //acquire the previous touch location CGPoint firstLocation = [touch previousLocationInView:[touch view]]; CGPoint location = [touch locationInView:[touch view]]; //preform all the same basic rig on both the current touch and previous touch CGPoint touchingPoint = [

Libgdx box2d issue with dimensions and camera zooming

99封情书 提交于 2019-12-01 08:34:37
问题 I've got a problem with Box2D . I'm making a simple 2D game, with a player shooting to enemies. I read that 1 unity in Box2D is equivalent to 1 meter so i should use little dimensions. I set world dimensions to 160x90 but here are the problems: Using little dimensions i had to zoom my camera that is set to 1280x720 but as you can see there is a big drop of quality in shapes, and also the movements of bodies are no longer flowing. And the max speed is still too slow even if the world steps at

Libgdx box2d body moves slow

只愿长相守 提交于 2019-12-01 06:29:30
This is a very simple scene with box2d. I tried different viewports and different screen sizes. I could not figure out why the body drops very slow. Actually, I am not quite sure that it is slow, the reason is maybe the viewport settings etc. This is main class: public class Main extends Game { LevelScreen levelScreen; @Override public void create () { levelScreen = new LevelScreen(); setScreen(levelScreen); } @Override public void render () { super.render(); } } And level screen: public class LevelScreen extends Stage implements Screen { private Batch batch; private Camera camera; private

MouseJointDef libgdx - draw a trajectory line like Angry Birds

倾然丶 夕夏残阳落幕 提交于 2019-12-01 05:07:06
问题 in libgdx game I want to touchDown and then drag somewhere and then on the release (touchUp) apply a directional force based on the distance and direction from the target body. When you touchdown the target body stays still and then on touchup the force is applied along the desired trajectory. (very similar to Angry birds - where you get to see the trajectory in dotted lines for the target body when you hold hack the slingshot - I want to do the same) So I guess that this might not be the

Calculate correct impluse or force to move a Box2D body to a specific position - Box2D

北慕城南 提交于 2019-12-01 01:13:55
i have a question about moving a Box2D body to a specific position without using this for example. body->SetTransform(targetVector,body->GetAngle()) I have some code which works for applyForce ( here ): const float destinationControl = 0.3f; b2Vec2 missilePosition = _physicalBody->GetPosition(); b2Vec2 diff = targetPosition - missilePosition; float dist = diff.Length(); if (dist > 0) { // compute the aiming direction b2Vec2 direction = b2Vec2(diff.x / dist, diff.y / dist); // get the current missile velocity because we will apply a force to compensate this. b2Vec2 currentVelocity =

Make a Vortex in Box2D

泪湿孤枕 提交于 2019-12-01 00:59:45
I'm trying to make a spiral vortex in Box2D on C++ / Objective C by applying forces. What I would like to realize is a vortex that pushes the bodies from a point, or that attract them. I guess I'll have to apply more than one force. My entry point in this problem is : I think I have to apply 3 forces : - An impulse to attract or repulse the body from the center. - An impulse to make it move laterally on a spiral, but... how ? - A torque to rotate the body itself if the impulse don't do it for me. I once did a rotating platform by making a circular sensor which applied a tangential speed change

How would I build Box2D to work in Code::Blocks/Mingw32(Windows)

放肆的年华 提交于 2019-11-30 20:56:36
hey the title pretty much says it all. i have been trying different methods from internet sources, but whenever i try something goes wrong..this is where i got Box2D in cMake , i get a bunch of errors when building it(i was going through the steps in the readme.txt, but onfortunately, theyre for Visual C++...) so im wondering hot to set this up as i guess a library (.lib or .a) and use it in my project(my friend passed me his library and when i loaded it in and tried #include ing the box2D headers, they didnt read at all(i got a list of undefined errors) also his box2d was i believe made for

Make a Vortex in Box2D

末鹿安然 提交于 2019-11-30 19:37:03
问题 I'm trying to make a spiral vortex in Box2D on C++ / Objective C by applying forces. What I would like to realize is a vortex that pushes the bodies from a point, or that attract them. I guess I'll have to apply more than one force. My entry point in this problem is : I think I have to apply 3 forces : - An impulse to attract or repulse the body from the center. - An impulse to make it move laterally on a spiral, but... how ? - A torque to rotate the body itself if the impulse don't do it for

box2d collision groups

旧巷老猫 提交于 2019-11-30 18:28:10
does anyone know whether bodies only collide when (body1.categoryBits & body2.maskBits) && (body1.maskBits & body2.categoryBits) ? or do they already collide when (body1.categoryBits & body2.maskBits) || (body1.maskBits & body2.categoryBits) ? If anyone is still looking for more explanations, I made a detailed tutorial here : http://aurelienribon.wordpress.com/2011/07/01/box2d-tutorial-collision-filtering/ From the Box2D manual : 6.2.3. Filtering Collision filtering is a system for preventing collision between shapes. For example, say you make a character that rides a bicycle. You want the