當前位置: 首頁>>代碼示例>>Java>>正文


Java World.destroyBody方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.physics.box2d.World.destroyBody方法的典型用法代碼示例。如果您正苦於以下問題:Java World.destroyBody方法的具體用法?Java World.destroyBody怎麽用?Java World.destroyBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.physics.box2d.World的用法示例。


在下文中一共展示了World.destroyBody方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: update

import com.badlogic.gdx.physics.box2d.World; //導入方法依賴的package包/類
public void update(World world) {

		for (int i = 0; i < balls.size; i++) {
			FireBall ball = balls.get(i);

			//檢查火球速度異常情況
			if (ball.getBody().getLinearVelocity().x == 0.2f && ball.STATE == State.STATE_RIGHT_FIREBALL) {
				ball.getBody().setLinearVelocity(1.0f, 0);
			} else if (ball.getBody().getLinearVelocity().x == -0.2f && ball.STATE == State.STATE_RIGHT_FIREBALL) {
				ball.getBody().setLinearVelocity(1.0f, 0);
			} else if (ball.getBody().getLinearVelocity().x == 0.2f && ball.STATE == State.STATE_LEFT_FIREBALL) {
				ball.getBody().setLinearVelocity(-1.0f, 0);
			} else if (ball.getBody().getLinearVelocity().x == -0.2f && ball.STATE == State.STATE_LEFT_FIREBALL) {
				ball.getBody().setLinearVelocity(-1.0f, 0);
			}

			//檢查是否Alive
			if (!checkAlive(ball)) {
				world.destroyBody(ball.getBody());
				balls.removeValue(ball, true);
			}
		}
	}
 
開發者ID:heyzqt,項目名稱:libGdx-xiyou,代碼行數:24,代碼來源:FireBallController.java

示例2: setStance

import com.badlogic.gdx.physics.box2d.World; //導入方法依賴的package包/類
private void setStance(Entity entity, String stance) {
	logger.info("set stance: " + stance);
	
	PhysicsComponent physics = Mappers.physics.get(entity);
	PlayerComponent player = Mappers.player.get(entity);
	AssetManager assetManager = Env.getGame().getAssetManager();
	
	World world = physicsSystem.getWorld();
	
	if (world.getBodyCount() > 0 && 
			physics.body != null) {
		world.destroyBody(physics.body);
	}
	
	PhysicsData physicsData = assetManager.get(stance, PhysicsData.class);
	physics.body = physicsData.createBody(world, entity);
	
	Array<Fixture> fixtures = physics.body.getFixtureList();
	player.fixture = fixtures.get(physicsData.getFixtureIdx("main"));
	player.feetSensor = fixtures.get(physicsData.getFixtureIdx("feet"));
	
	NodeComponent node = Mappers.node.get(entity);
	NodeUtils.computeWorld(entity);
	
	physics.body.setTransform(node.position, node.angle);
}
 
開發者ID:saltares,項目名稱:libgdxjam,代碼行數:27,代碼來源:PlayerSystem.java

示例3: checkDestroy

import com.badlogic.gdx.physics.box2d.World; //導入方法依賴的package包/類
public void checkDestroy(float x, float y)
{
	if(Utils.pointInRectangle(getBoundingRectangle(),new Vector2(x, y))) {
		World world = getBody().getWorld();
		world.destroyBody(getBody());
		((BaseGameScene)getGameService().getCurrentScene()).remove(this);
	}
}
 
開發者ID:game-libgdx-unity,項目名稱:GDX-Engine,代碼行數:9,代碼來源:Pig.java

示例4: disposeBox2D

import com.badlogic.gdx.physics.box2d.World; //導入方法依賴的package包/類
public void disposeBox2D(int levelID) {
	World world = Game_AI_TestBed.instance().getLevel(levelID).getWorldBox2D();
	if (body != null) {
		body.setUserData(null);
		world.destroyBody(body);
		body = null;
	} else {
		//occurs during double kill calls from sprite sim, need some sort of queue remove system? also one for stopping further code processing
		Logger.warn("tried to kill phys body when it was already null'd");
	}
}
 
開發者ID:Corosauce,項目名稱:AI_TestBed_v3,代碼行數:12,代碼來源:PhysicsData.java

示例5: process

import com.badlogic.gdx.physics.box2d.World; //導入方法依賴的package包/類
@Override
protected void process(int entityId) {
    Bomb bomb = mBomb.get(entityId);
    State state = mState.get(entityId);
    RigidBody rigidBody = mRigidBody.get(entityId);

    Body body = rigidBody.body;

    bomb.countDown -= world.getDelta();

    if (bomb.countDown <= 0) {
        // explode
        bomb.state = Bomb.State.EXPLODING;
    }

    switch (bomb.state) {
        case EXPLODING:
            state.setCurrentState("exploding");
            GameManager.getInstance().playSound("Explosion.ogg", 1.0f, MathUtils.random(0.6f, 0.8f), 0);
            // create explosion
            ActorBuilder actorBuilder = ActorBuilder.init(body.getWorld(), world);
            actorBuilder.createExplosion(body.getPosition().x, body.getPosition().y, bomb.power);

            // destroy itself
            World b2dWorld = body.getWorld();
            b2dWorld.destroyBody(body);
            world.delete(entityId);
            break;
        case MOVING_UP:
            if (checkMovable(body, fromV.set(body.getPosition()), toV.set(body.getPosition().x, body.getPosition().y + 0.55f))) {
                body.setLinearVelocity(0, bomb.speed);
            } else {
                body.setLinearVelocity(0, 0);
                body.setTransform(MathUtils.floor(body.getPosition().x) + 0.5f, MathUtils.floor(body.getPosition().y) + 0.5f, 0);
                bomb.state = Bomb.State.NORMAL;
            }
            break;
        case MOVING_DOWN:
            if (checkMovable(body, fromV.set(body.getPosition()), toV.set(body.getPosition().x, body.getPosition().y - 0.55f))) {
                body.setLinearVelocity(0, -bomb.speed);
            } else {
                body.setLinearVelocity(0, 0);
                body.setTransform(MathUtils.floor(body.getPosition().x) + 0.5f, MathUtils.floor(body.getPosition().y) + 0.5f, 0);
                bomb.state = Bomb.State.NORMAL;
            }
            break;
        case MOVING_LEFT:
            if (checkMovable(body, fromV.set(body.getPosition()), toV.set(body.getPosition().x - 0.55f, body.getPosition().y))) {
                body.setLinearVelocity(-bomb.speed, 0);
            } else {
                body.setLinearVelocity(0, 0);
                body.setTransform(MathUtils.floor(body.getPosition().x) + 0.5f, MathUtils.floor(body.getPosition().y) + 0.5f, 0);
                bomb.state = Bomb.State.NORMAL;
            }
            break;

        case MOVING_RIGHT:
            if (checkMovable(body, fromV.set(body.getPosition()), toV.set(body.getPosition().x + 0.55f, body.getPosition().y))) {
                body.setLinearVelocity(bomb.speed, 0);
            } else {
                body.setLinearVelocity(0, 0);
                body.setTransform(MathUtils.floor(body.getPosition().x) + 0.5f, MathUtils.floor(body.getPosition().y) + 0.5f, 0);
                bomb.state = Bomb.State.NORMAL;
            }
            break;
        case NORMAL:
        default:
            state.setCurrentState("normal");
            break;
    }
}
 
開發者ID:yichen0831,項目名稱:Bomberman_libGdx,代碼行數:72,代碼來源:BombSystem.java


注:本文中的com.badlogic.gdx.physics.box2d.World.destroyBody方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。