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


Java Body.setBullet方法代碼示例

本文整理匯總了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);
}
 
開發者ID:StringMon,項目名稱:homescreenarcade,代碼行數:13,代碼來源:Ball.java

示例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;
   }
 
開發者ID:game-libgdx-unity,項目名稱:GDX-Engine,代碼行數:28,代碼來源:Bird.java


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