com.badlogic.gdx.physics.box2d.Body.setActive()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中com.badlogic.gdx.physics.box2d.Body.setActive()方法的一些代码示例,展示了Body.setActive()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.setActive()方法的具体详情如下:
包路径:com.badlogic.gdx.physics.box2d.Body
类名称:Body
方法名:setActive

Body.setActive介绍

[英]Set the active state of the body. An inactive body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected. You may continue to create/destroy fixtures and joints on inactive bodies. Fixtures on an inactive body are implicitly inactive and will not participate in collisions, ray-casts, or queries. Joints connected to an inactive body are implicitly inactive. An inactive body is still owned by a b2World object and remains in the body list.
[中]

代码示例

代码示例来源:origin: dozingcat/Vector-Pinball

/** Makes all targets visible by calling Body.setActive(true) on each target body */
public void makeAllTargetsVisible() {
  int bsize = allBodies.size();
  for (int i=0; i<bsize; i++) {
    allBodies.get(i).setActive(true);
  }
}

代码示例来源:origin: manuelbua/uracer-kotd

public void setActive (boolean active) {
  if (active != body.isActive()) {
    body.setActive(active);
  }
}

代码示例来源:origin: dozingcat/Vector-Pinball

public void setRetracted(boolean retracted) {
  if (retracted!=this.isRetracted()) {
    wallBody.setActive(!retracted);
  }
}

代码示例来源:origin: MovingBlocks/box2d-editor

@Override
  public void onEvent(int type, BaseTween<?> source) {
    if (idx < ballModels.length) {
      ballModels[idx].setAwake(true);
      ballModels[idx].setActive(true);
      idx += 1;
    }
  }
}).repeat(-1, 0.1f).start(tweenManager);

代码示例来源:origin: BrentAureli/SuperMario

public Enemy(PlayScreen screen, float x, float y){
  this.world = screen.getWorld();
  this.screen = screen;
  setPosition(x, y);
  defineEnemy();
  velocity = new Vector2(-1, -2);
  b2body.setActive(false);
}

代码示例来源:origin: dozingcat/Vector-Pinball

@Override public void handleCollision(Ball ball, Body bodyHit, final Field field) {
  bodyHit.setActive(false);
  // if all hit, notify delegate and check for reset parameter
  if (allTargetsHit()) {
    field.getDelegate().allDropTargetsInGroupHit(field, this);
    float restoreTime = asFloat(this.parameters.get(RESET_DELAY_PROPERTY));
    if (restoreTime>0) {
      field.scheduleAction((long)(restoreTime*1000), new Runnable() {
        @Override
        public void run() {
          makeAllTargetsVisible();
        }
      });
    }
  }
}

代码示例来源:origin: MovingBlocks/box2d-editor

float angle = rand.nextFloat() * MathUtils.PI * 2;
ballModels[i].setActive(false);
ballModels[i].setLinearVelocity(vec.set(0, 0));
ballModels[i].setAngularVelocity(0);

代码示例来源:origin: BrentAureli/SuperMario

public void update(float dt){
  //handle user input first
  handleInput(dt);
  handleSpawningItems();
  //takes 1 step in the physics simulation(60 times per second)
  world.step(1 / 60f, 6, 2);
  player.update(dt);
  for(Enemy enemy : creator.getEnemies()) {
    enemy.update(dt);
    if(enemy.getX() < player.getX() + 224 / MarioBros.PPM) {
      enemy.b2body.setActive(true);
    }
  }
  for(Item item : items)
    item.update(dt);
  hud.update(dt);
  //attach our gamecam to our players.x coordinate
  if(player.currentState != Mario.State.DEAD) {
    gamecam.position.x = player.b2body.getPosition().x;
  }
  //update our gamecam with correct coordinates after changes
  gamecam.update();
  //tell our renderer to draw only what our camera can see in our game world.
  renderer.setView(gamecam);
}

相关文章