Example usage for com.badlogic.gdx.physics.box2d Fixture setRestitution

List of usage examples for com.badlogic.gdx.physics.box2d Fixture setRestitution

Introduction

In this page you can find the example usage for com.badlogic.gdx.physics.box2d Fixture setRestitution.

Prototype

public void setRestitution(float restitution) 

Source Link

Document

Set the coefficient of restitution.

Usage

From source file:com.agateau.pixelwheels.utils.Box2DUtils.java

License:Open Source License

public static void setBodyRestitution(Body body, float restitution) {
    for (Fixture fixture : body.getFixtureList()) {
        fixture.setRestitution(restitution);
    }/* w  ww  . j  a v a2s .c o  m*/
}

From source file:edu.lehigh.cse.lol.Actor.java

License:Open Source License

/**
 * Adjust the default physics settings (density, elasticity, friction) for
 * this actor/*from www  .  ja  v a  2 s.  c  om*/
 *
 * @param density    New density of the actor
 * @param elasticity New elasticity of the actor
 * @param friction   New friction of the actor
 */
public Actor setPhysics(float density, float elasticity, float friction) {
    for (Fixture f : mBody.getFixtureList()) {
        f.setDensity(density);
        f.setRestitution(elasticity);
        f.setFriction(friction);
    }
    mBody.resetMassData();
    return this;
}

From source file:org.catrobat.catroid.physics.PhysicsObject.java

License:Open Source License

public void setBounceFactor(float bounceFactor) {
    if (bounceFactor < MIN_BOUNCE_FACTOR) {
        bounceFactor = MIN_BOUNCE_FACTOR;
    }/*from   www  .  j a  va2 s  .  co m*/
    fixtureDef.restitution = bounceFactor;
    for (Fixture fixture : body.getFixtureList()) {
        fixture.setRestitution(bounceFactor);
    }
}

From source file:se.anyro.snr.bodies.Laser.java

License:Apache License

public Laser(float y) {
    super(0, y);//from  w  ww  .j  a  v  a 2  s. com

    mCollider = true;

    mPosition = new Vector2(0, y);
    mWidth = 17f / 320f * Physics.GAME_WIDTH;
    mHeight = 30f / 480 * Physics.GAME_HEIGHT;

    // Init graphics
    mCannonDrawable = SwipeNRoll.sResources.getDrawable(R.drawable.laser_cannon);
    mBeamDrawable = SwipeNRoll.sResources.getDrawable(R.drawable.laser);

    // Calculate cannon bounds
    int right = SizeUtil.getScreenWidth();
    int left = right - SizeUtil.toScreen(mWidth);
    mScreenPos = new Point();
    SizeUtil.toScreen(0, y, mScreenPos);
    int halfHeight = SizeUtil.toScreen(mHeight / 2f);
    int top = mScreenPos.y - halfHeight;
    int bottom = mScreenPos.y + halfHeight;
    mCannonDrawable.setBounds(left, top, right, bottom);

    // Calculate beam bounds
    mBeamBounds.right = left;
    mBeamBounds.left = 0;
    mHeight = 6f / 480f * Physics.GAME_HEIGHT;
    halfHeight = SizeUtil.toScreen(mHeight / 2f);
    mBeamBounds.top = mScreenPos.y - halfHeight;
    mBeamBounds.bottom = mScreenPos.y + halfHeight;
    mBeamDrawable.setBounds(mBeamBounds);

    // Init physics
    PolygonShape polyShape = new PolygonShape();
    polyShape.setAsBox(Physics.HALF_WIDTH, mHeight / 2f);

    Fixture mFixture = mBody.createFixture(polyShape, 0.1f);
    mFixture.setRestitution(0.2f);

    polyShape.dispose();
}