当前位置: 首页>>代码示例>>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;未经允许,请勿转载。