/** Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of * application is not at the center of mass. This wakes up the body. * @param impulseX the world impulse vector on the x-axis, usually in N-seconds or kg-m/s. * @param impulseY the world impulse vector on the y-axis, usually in N-seconds or kg-m/s. * @param pointX the world position of the point of application on the x-axis. * @param pointY the world position of the point of application on the y-axis. */ public void applyLinearImpulse (float impulseX, float impulseY, float pointX, float pointY, boolean wake) { tmp.set(impulseX, impulseY); tmp2.set(pointX, pointY); body.applyLinearImpulse(tmp, tmp2, wake); }
/** Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of * application is not at the center of mass. This wakes up the body. * @param impulse the world impulse vector, usually in N-seconds or kg-m/s. * @param point the world position of the point of application. */ public void applyLinearImpulse (Vector2 impulse, Vector2 point, boolean wake) { tmp.set(impulse.x, impulse.y); tmp2.set(point.x, point.y); body.applyLinearImpulse(tmp, tmp2, wake); }
f.x = -f.x; f.y = -f.y; b.applyLinearImpulse(f, p, true);
f.x = -f.x; f.y = -f.y; b.applyLinearImpulse(f, p, true);
va.x -= pInvMass * f.x; va.y -= pInvMass * f.y; b.applyLinearImpulse(f, p, true);
velData.x -= particleInvMass * f.x; velData.y -= particleInvMass * f.y; b.applyLinearImpulse(f, p, true);
f.x = fdn * b.x; f.y = fdn * b.y; body.applyLinearImpulse(f, p, true);
f.x = -f.x; f.y = -f.y; b.applyLinearImpulse(f, p, true);
f.x = -f.x; f.y = -f.y; b.applyLinearImpulse(f, p, true);
va.x -= pInvMass * f.x; va.y -= pInvMass * f.y; b.applyLinearImpulse(f, p, true);
velData.x -= particleInvMass * f.x; velData.y -= particleInvMass * f.y; b.applyLinearImpulse(f, p, true);
f.x = fdn * b.x; f.y = fdn * b.y; body.applyLinearImpulse(f, p, true);
public void random() { int childCount = mViewgroup.getChildCount(); for (int i = 0; i < childCount; i++) { Vec2 impulse = new Vec2(random.nextInt(1000) - 1000, random.nextInt(1000) - 1000); View view = mViewgroup.getChildAt(i); Body body = (Body) view.getTag(R.id.mobike_body_tag); if(body != null){ body.applyLinearImpulse(impulse, body.getPosition(),true); } } }
public void onSensorChanged(float x,float y) { int childCount = mViewgroup.getChildCount(); for (int i = 0; i < childCount; i++) { Vec2 impulse = new Vec2(x, y); View view = mViewgroup.getChildAt(i); Body body = (Body) view.getTag(R.id.mobike_body_tag); if(body != null){ body.applyLinearImpulse(impulse, body.getPosition(),true); } } }
public void pushBall() { if(stopWorld) { return; } stopWorld = true; Body ball = createBall(40*n, 40*n); int velocity = ballParameters.getVelocity(); int angleDeg = ballParameters.getAngle(); int vx = (int) (velocity*Math.cos(Math.toRadians(angleDeg))); int vy = (int) (velocity*Math.sin(Math.toRadians(angleDeg))); ball.applyLinearImpulse(vx, vy, ball.getPosition().x, ball.getPosition().y, true); stopWorld = false; }
private void applyLinearImpulse(float x, float y, View view) { Body body = (Body) view.getTag(R.id.wd_view_body_tag); if (null != body) { //N秒或kg-m / s为单位 Vec2 vec2 = new Vec2(x, y); //对body施加一个冲量 /// 应用一个冲量到一个点上,这将立即改变速度。(这句话的意思是突然在一个点上作用一个力) /// 如果这个点不再应用程序的质心上,它还会修改角速度. 唤醒 body. /// @param impulse world 的矢量冲量, 通常 N-seconds or kg-m/s. /// @param point 应用里面的某个点的 world 位置 body.applyLinearImpulse(vec2, body.getPosition(), true); } } }
void applyImpulse(GameObjectInstance aInstance, Force aForce) { Body theBody = dynamicObjects.get(aInstance); if (theBody != null) { theBody.applyLinearImpulse(new Vec2(aForce.forceX, aForce.forceY), theBody.getWorldCenter()); } }
if (keycode == Input.Keys.UP) { Body body = player.getBody(); body.applyLinearImpulse(new Vector2(0, 30000), body.getWorldCenter(), true); }
f.x = -f.x; f.y = -f.y; b.applyLinearImpulse(f, p, true);
super(pX, pY, pTextureRegion, pVertexBufferObjectManager); body = PhysicsFactory.createCircleBody(mPhysicsWorld, this, BodyType.DynamicBody, PhysicsFactory.createFixtureDef(0, 1, 0)); body.applyLinearImpulse(((float)5),(float) 5, body.getWorldCenter().x, body.getWorldCenter().y); mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(this, body, true, true)); scene.attachChild(this);