當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。