本文整理汇总了Java中com.badlogic.gdx.physics.box2d.Body.setBullet方法的典型用法代码示例。如果您正苦于以下问题:Java Body.setBullet方法的具体用法?Java Body.setBullet怎么用?Java Body.setBullet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.physics.box2d.Body
的用法示例。
在下文中一共展示了Body.setBullet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.badlogic.gdx.physics.box2d.Body; //导入方法依赖的package包/类
public static Ball create(World world, float x, float y, float radius,
Color primaryColor, Color secondaryColor) {
Body ballBody = Box2DFactory.createCircle(world, x, y, radius, false);
ballBody.setBullet(true);
// Default is radius of 0.5, if different we want the mass to be the same (could be
// configurable if needed), so adjust density proportional to square of the radius.
if (radius != 0.5f) {
ballBody.getFixtureList().get(0).setDensity((0.5f*0.5f) / (radius*radius));
ballBody.resetMassData();
}
return new Ball(ballBody, primaryColor, secondaryColor);
}
示例2: onTouchUp
import com.badlogic.gdx.physics.box2d.Body; //导入方法依赖的package包/类
@Override
public boolean onTouchUp(TouchEvent e) {
if (status != Status.touched) {
return true;
}
// If mouse is up when dragging the bird
// fire the bird
float distanceX = getCenterX() - sling.getCenterX();
float distanceY = getCenterY() - sling.getCenterY();
// Here we have velocityX and velocityY of bird
float velocityX = distanceX * -1 / 5;
float velocityY = distanceY * -1 / 5;
Vector2 birdVelocity = new Vector2(velocityX, velocityY);
// get PhysicManager from gameService
PhysicsManager physicsManager = getGameService().getService(
PhysicsManager.class);
// create new physicObject in physicsManager
Body birdBody = physicsManager.addDynamicCircleObject(this,
getRegionWidth() / 2, 4f, 0.8f, 0.5f);
// Set above velocity for the bird body
birdBody.setLinearVelocity(birdVelocity);
// set bullet, it will make game run preciously
birdBody.setBullet(true);
// update the bird's status
status = Status.released;
return false;
}