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