@Override public void run () { world.destroyBody(toRemove); } });
@Override public boolean touchDown (int x, int y, int pointer, int newParam) { // translate the mouse coordinates to world coordinates testPoint.set(x, y, 0); camera.unproject(testPoint); // ask the world which bodies are within the given // bounding box around the mouse pointer hitBody = null; world.QueryAABB(callback, testPoint.x - 0.1f, testPoint.y - 0.1f, testPoint.x + 0.1f, testPoint.y + 0.1f); // if we hit something we create a new mouse joint // and attach it to the hit body. if (hitBody != null) { MouseJointDef def = new MouseJointDef(); def.bodyA = groundBody; def.bodyB = hitBody; def.collideConnected = true; def.target.set(testPoint.x, testPoint.y); def.maxForce = 1000.0f * hitBody.getMass(); mouseJoint = (MouseJoint)world.createJoint(def); hitBody.setAwake(true); } else { for (Body box : boxes) world.destroyBody(box); boxes.clear(); createBoxes(); } return false; }
@Override public boolean keyDown (int keyCode) { if (keyCode == Input.Keys.COMMA) { if (m_bullet != null) { world.destroyBody(m_bullet); m_bullet = null; } { CircleShape shape = new CircleShape(); shape.setRadius(0.25f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; fd.restitution = 0.05f; BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; bd.bullet = true; bd.position.set(-31, 5); m_bullet = world.createBody(bd); m_bullet.createFixture(fd); m_bullet.setLinearVelocity(new Vector2(400, 0)); } } return false; }
public void update(float dt){ if(toDestroy && !destroyed){ world.destroyBody(body); destroyed = true; } }
/** * Removes a ball from play, but does not call doBallLost for end-of-ball processing even if * no balls remain. */ public void removeBallWithoutBallLoss(Ball ball) { world.destroyBody(ball.getBody()); this.balls.remove(ball); }
/** * Destroys every static body that has been created using the manager. */ public void destroyPhysics() { for (Body body : bodies) { world.destroyBody(body); } bodies.clear(); }
public void removeBody(b2BodyDefModel body) { removeDependJoint(body); if (body.body != null) { PhysicalWorld.WORLD.destroyBody(body.body); body.body = null; this.bodyDefModels.remove(body); } }
@Override public void dispose () { super.dispose(); box2dWorld.destroyBody(body); }
private void clearWorld() { ballsBodies.clear(); ballsSprites.clear(); Array<Body> bodies = new Array<Body>(); world.getBodies(bodies); for (Body b : bodies) world.destroyBody(b); }
/** Removes a ball from play. If there are no other balls on the field, calls doBallLost. */ public void removeBall(Ball ball) { world.destroyBody(ball.getBody()); this.balls.remove(ball); if (this.balls.size()==0) { this.doBallLost(); } }
public void removeCircle(GDXCircle circle) { screen.getLevel().getCircles().remove(circle); if(bodies.containsKey(circle)) screen.getWorld().destroyBody(bodies.remove(circle)); }
public void stopSimulation() { for (PolygonActor actor : meshs) { if (actor != null) { actor.dispose(); } } meshs.clear(); //clear all bodys this.clear(); if (null != screenBox) PhysicalWorld.WORLD.destroyBody(screenBox); screenBox = null; BuildWorld.stopSimulation(); }
public void removePolygon(GDXPolygon polygon) { Log.log("PolygonMode.removePolygon", polygon.toString()); screen.getWorld().destroyBody(bodies.remove(polygon)); screen.getLevel().getPolygons().remove(polygon); tiledMeshRenderer = null; }
@Override public CompletionEnum execute(float dt) { Body object = executor.getPhysicsObject(name); if(object != null) executor.getWorld().destroyBody(object); else Log.error("BodyRemoveManifestation.execute", "Box2d body null with name: " + name); return CompletionEnum.COMPLETED; }
public void addCircle(GDXCircle circle) { Log.log("CircleMode.addCircle", circle.toString()); if(bodies.containsKey(circle)) screen.getWorld().destroyBody(bodies.remove(circle)); Body body = circle.createFixture(screen.getWorld(), !screen.isLive()); if(body != null){ bodies.put(circle, body); if(!screen.getLevel().getCircles().contains(circle)) screen.getLevel().getCircles().add(circle); } }
public boolean addPolygon(GDXPolygon polygon){ Log.log("PolygonMode.addPolygon", polygon.toString()); if(bodies.containsKey(polygon)) screen.getWorld().destroyBody(bodies.remove(polygon)); Body body = polygon.createFixture(screen.getWorld(), !screen.isLive()); if(body != null){ if(!screen.getLevel().getPolygons().contains(polygon)) screen.getLevel().getPolygons().add(polygon); bodies.put(polygon, body); } tiledMeshRenderer = null; return body != null; }
private void update(Body body) { if (!BodyUtils.bodyInBounds(body)) { if (BodyUtils.bodyIsEnemy(body) && !runner.isHit()) { createEnemy(); } world.destroyBody(body); } }
@Override protected void process(int entityId) { // Explosion explosion = mExplosion.get(entityId); RigidBody rigidBody = mRigidBody.get(entityId); State state = mState.get(entityId); if (state.getStateTime() > 0.75f) { rigidBody.body.getWorld().destroyBody(rigidBody.body); world.delete(entityId); } }
/** * Ends a game in progress by removing all balls in play, calling setGameInProgress(false) * on the GameState, and setting a "Game Over" message for display by the score view. */ public void endGame() { audioPlayer.playStart(); // play startup sound at end of game for(Ball ball : this.getBalls()) { world.destroyBody(ball.getBody()); } this.balls.clear(); this.getGameState().setGameInProgress(false); this.showGameMessage("Game Over", 2500); getDelegate().gameEnded(this); }
public void update(float dt){ stateTime += dt; setRegion(fireAnimation.getKeyFrame(stateTime, true)); setPosition(b2body.getPosition().x - getWidth() / 2, b2body.getPosition().y - getHeight() / 2); if((stateTime > 3 || setToDestroy) && !destroyed) { world.destroyBody(b2body); destroyed = true; } if(b2body.getLinearVelocity().y > 2f) b2body.setLinearVelocity(b2body.getLinearVelocity().x, 2f); if((fireRight && b2body.getLinearVelocity().x < 0) || (!fireRight && b2body.getLinearVelocity().x > 0)) setToDestroy(); }