本文整理匯總了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;
}