当前位置: 首页>>代码示例>>Java>>正文


Java Fixture.setRestitution方法代码示例

本文整理汇总了Java中com.badlogic.gdx.physics.box2d.Fixture.setRestitution方法的典型用法代码示例。如果您正苦于以下问题:Java Fixture.setRestitution方法的具体用法?Java Fixture.setRestitution怎么用?Java Fixture.setRestitution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.physics.box2d.Fixture的用法示例。


在下文中一共展示了Fixture.setRestitution方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initBall

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
private void initBall() {
    float radius = 26;

    mBall = new Circle(0.f, 0.f, radius);

    mBallTextureRegion = new TextureRegion(new Texture(Gdx.files.internal("ball.png")));

    // create physics body
    BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyDef.BodyType.DynamicBody;
    bodyDef.position.set(mBall.x, mBall.y);

    CircleShape ballShape = new CircleShape();
    ballShape.setRadius(mBall.radius - 2.f);

    mBallBody = mWorld.createBody(bodyDef);
    mBallBody.setUserData(new BodyUserDate(BODY_USER_DATA_TYPE_BALL));
    Fixture fixture = mBallBody.createFixture(ballShape, 0.5f);
    fixture.setFriction(BALL_FRICTION_BASE);
    fixture.setRestitution(0.4f);

    ballShape.dispose();
}
 
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:24,代码来源:Balanceball.java

示例2: create

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
@Override
public void create() {
    getComponentByType(TextureComponent.class).textureRegion = new TextureRegion(
            new Texture(Gdx.files.internal("stick_leaf.png")));

    PositionComponent positionComponent = getComponentByType(PositionComponent.class);
    SizeComponent sizeComponent = getComponentByType(SizeComponent.class);

    // create physics body
    PhysicsComponent physicsComponent = getComponentByType(PhysicsComponent.class);

    BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyDef.BodyType.StaticBody;
    bodyDef.position.set(
            positionComponent.position.x,
            positionComponent.position.y);

    // Create a polygon shape
    PolygonShape leafPhysicsBox = new PolygonShape();
    leafPhysicsBox.setAsBox(sizeComponent.width * 0.5f, sizeComponent.height * 0.5f);

    PhysicsSystem physicsSystem = mEngine.getFirstSystemOfType(PhysicsSystem.class);
    physicsComponent.body = physicsSystem.getWorld().createBody(bodyDef);
    physicsComponent.body.setUserData(
            new PhysicsSystem.BodyUserDate(PhysicsSystem.BODY_USER_DATA_TYPE_OTHER));
    Fixture fixture = physicsComponent.body.createFixture(leafPhysicsBox, 0.f);
    fixture.setFriction(0.4f);
    fixture.setRestitution(0.4f);

    leafPhysicsBox.dispose();
}
 
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:32,代码来源:StickLeafEntity.java

示例3: create

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
@Override
public void create() {
    getComponentByType(TextureComponent.class).textureRegion = new TextureRegion(
            new Texture(Gdx.files.internal("ball.png")));

    SizeComponent sizeComponent = getComponentByType(SizeComponent.class);
    sizeComponent.width = RADIUS * 2.f;
    sizeComponent.height = RADIUS * 2.f;

    // create physics body
    PhysicsComponent physicsComponent = getComponentByType(PhysicsComponent.class);

    BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyDef.BodyType.DynamicBody;
    bodyDef.position.set(mBallStartPosition.x, mBallStartPosition.y);

    CircleShape ballShape = new CircleShape();
    ballShape.setRadius(RADIUS - 2.f);

    PhysicsSystem physicsSystem = mEngine.getFirstSystemOfType(PhysicsSystem.class);
    physicsComponent.body = physicsSystem.getWorld().createBody(bodyDef);
    physicsComponent.body.setUserData(new PhysicsSystem.BodyUserDate(PhysicsSystem.BODY_USER_DATA_TYPE_BALL));
    Fixture fixture = physicsComponent.body.createFixture(ballShape, 0.5f);
    fixture.setFriction(BALL_FRICTION_BASE);
    fixture.setRestitution(0.4f);

    ballShape.dispose();
}
 
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:29,代码来源:BallEntity.java

示例4: restitution

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
/**
 * Sets restitution of Tabody object
 * @param rest Restitution (0 to 1)
 * @return The same Tabody object
 */
public Tabody restitution(float rest) {
    for(Fixture f : this.body.getFixtureList()) {
        f.setRestitution(rest);
    }
    return this;
}
 
开发者ID:tavuntu,项目名称:tabox2d,代码行数:12,代码来源:Tabox2D.java

示例5: initStick

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
private void initStick() {
    mStickLeafTexture = new Texture(Gdx.files.internal("stick_leaf.png"));
    mStickHandleTexture = new Texture(Gdx.files.internal("stick_handle.png"));

    final float handleWidth = 20.f;
    final float handleHeight = mWorldHeight * 0.4f; // 40% of screen height

    mStickHandleDimensions = new Rectangle(
            (mWorldWidth / 2.f) - (handleWidth / 2.f),
            0,
            handleWidth,
            handleHeight
    );

    final float leafWidth = (mWorldWidth / 3.f) * 2.f; // 2/3 of screen width
    final float leafHeight = 20.f;

    mStickLeafDimen = new Rectangle(
            (mWorldWidth / 2) - (leafWidth / 2),
            handleHeight,
            leafWidth,
            leafHeight
    );

    // create physics body
    BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyDef.BodyType.StaticBody;
    bodyDef.position.set(
            mStickLeafDimen.x + (mStickLeafDimen.width / 2),
            mStickLeafDimen.y + (mStickLeafDimen.height / 2));

    // Create a polygon shape
    PolygonShape leafPhysicsBox = new PolygonShape();
    leafPhysicsBox.setAsBox(mStickLeafDimen.width / 2, mStickLeafDimen.height /2);

    Body body = mWorld.createBody(bodyDef);
    body.setUserData(new BodyUserDate(BODY_USER_DATA_TYPE_OTHER));
    Fixture fixture = body.createFixture(leafPhysicsBox, 0.f);
    fixture.setFriction(0.4f);
    fixture.setRestitution(0.4f);

    leafPhysicsBox.dispose();
}
 
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:44,代码来源:Balanceball.java


注:本文中的com.badlogic.gdx.physics.box2d.Fixture.setRestitution方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。