本文整理汇总了Java中com.badlogic.gdx.physics.box2d.Fixture.setFriction方法的典型用法代码示例。如果您正苦于以下问题:Java Fixture.setFriction方法的具体用法?Java Fixture.setFriction怎么用?Java Fixture.setFriction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.physics.box2d.Fixture
的用法示例。
在下文中一共展示了Fixture.setFriction方法的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();
}
示例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();
}
示例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();
}
示例4: friction
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
/**
* Sets friction of Tabody object
* @param fri Friction (0 to 1)
* @return The same Tabody object
*/
public Tabody friction(float fri) {
for(Fixture f : this.body.getFixtureList()) {
f.setFriction(fri);
}
return this;
}
示例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();
}