本文整理汇总了Java中com.badlogic.gdx.math.MathUtils.sin方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.sin方法的具体用法?Java MathUtils.sin怎么用?Java MathUtils.sin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.MathUtils
的用法示例。
在下文中一共展示了MathUtils.sin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
public void draw(IFieldRenderer renderer) {
CircleShape shape = (CircleShape)body.getFixtureList().get(0).getShape();
Vector2 center = body.getPosition();
float radius = shape.getRadius();
renderer.fillCircle(center.x, center.y, radius, primaryColor);
// Draw a smaller circle to show the ball's rotation.
float angle = body.getAngle();
float smallCenterX = center.x + (radius / 2) * MathUtils.cos(angle);
float smallCenterY = center.y + (radius / 2) * MathUtils.sin(angle);
renderer.fillCircle(smallCenterX, smallCenterY, radius / 4, secondaryColor);
}
示例2: drawLayer2
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
@Override
public void drawLayer2(Tile tile){
TurretEntity entity = tile.entity();
if(entity.target != null &&
Angles.angleDist(entity.rotation, Angles.angle(tile.worldx(), tile.worldy(), entity.target.x, entity.target.y)) <= cone){
Angles.translation(entity.rotation, 4f);
float x = tile.worldx() + Angles.x(), y = tile.worldy() + Angles.y();
float x2 = entity.target.x, y2 = entity.target.y;
float lighten = (MathUtils.sin(Timers.time()/1.2f) + 1f) / 10f;
Draw.color(Tmp.c1.set(beamColor).mul(1f + lighten, 1f + lighten, 1f + lighten, 1f));
Draw.alpha(0.3f);
Draw.thickness(4f);
Draw.line(x, y, x2, y2);
Draw.thickness(2f);
Draw.rect("circle", x2, y2, 7f, 7f);
Draw.alpha(1f);
Draw.thickness(2f);
Draw.line(x, y, x2, y2);
Draw.thickness(1f);
Draw.rect("circle", x2, y2, 5f, 5f);
}
Draw.reset();
}
示例3: handleFakeTouch
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
void handleFakeTouch() {
if (Gdx.input.justTouched()) {
fingerDown = true;
}
if (fingerDown) {
if (Gdx.input.getDeltaX() != 0) {
float swipeDelta = -Gdx.input.getDeltaX();
xOffsetFakeTarget += swipeDelta / PIXEL_TO_XOFFSET_FAKE_RATIO;
if (xOffsetFakeTarget < 0)
xOffsetFakeTarget = 0;
else if (xOffsetFakeTarget > 1)
xOffsetFakeTarget = 1;
}
}
if (!Gdx.input.isTouched())
fingerDown = false;
float offsetDelta = xOffsetFakeTarget - xOffsetFake;
float offsetVelocity = offsetMaxVelocity * MathUtils.sin(offsetDelta * MathUtils.PI);
if (offsetDelta < 0) { //moving left
offsetVelocity -= offsetMinVelocity;
} else if (offsetDelta > 0) {//moving right
offsetVelocity += offsetMinVelocity;
}
float offsetAdder = offsetVelocity * Gdx.graphics.getDeltaTime();
if (Math.abs(offsetAdder) >= Math.abs(offsetDelta)) {
xOffsetFake = xOffsetFakeTarget;
} else {
xOffsetFake += offsetAdder;
}
}
示例4: update
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
public void update() {
mAnimationTime += Gdx.graphics.getDeltaTime();
SizeComponent sizeComponent = getComponentByType(SizeComponent.class);
float size = (RADIUS * 2.f) + (MathUtils.sin(mAnimationTime * (mIsPointLeft ? 4.0f : 4.1f)) * 2.f);
sizeComponent.width = size;
sizeComponent.height = size;
}
示例5: updateSpecialXOffsets
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
private void updateSpecialXOffsets() {
//Handle xOffsetFake
offsetDelta = xOffsetFakeTarget - xOffsetFake;
offsetVelocity = offsetMaxVelocity * MathUtils.sin(offsetDelta * MathUtils.PI);
if (offsetDelta < 0) { // moving left
offsetVelocity -= offsetMinVelocity;
} else if (offsetDelta > 0) { // moving right
offsetVelocity += offsetMinVelocity;
}
float offsetAdder = offsetVelocity * Gdx.graphics.getDeltaTime();
if (Math.abs(offsetAdder) >= Math.abs(offsetDelta)) {
xOffsetFake = xOffsetFakeTarget;
} else {
xOffsetFake += offsetAdder;
}
//Handle xOffsetSmooth
offsetDelta = xOffset - xOffsetSmooth;
offsetVelocity = offsetMaxVelocity*MathUtils.sin(offsetDelta*MathUtils.PI);
if (offsetDelta < 0){ // moving left
offsetVelocity -= offsetMinVelocity;
} else if (offsetDelta > 0){ // moving right
offsetVelocity += offsetMinVelocity;
}
offsetAdder = offsetVelocity * Gdx.graphics.getDeltaTime();
if (Math.abs(offsetAdder) >= Math.abs(offsetDelta)){
xOffsetSmooth = xOffset;
catchingUp = false;
} else {
xOffsetSmooth += offsetAdder;
}
//Handle xOffsetLooping. Uses xOffset if not looping/catching up. Otherwise, use same value as xOffsetSmooth.
if (!catchingUp){
final float offsetChange = xOffset - previousOffset;
if (offsetChange >= DELTA_OFFSET_MIN_LOOPING || -offsetChange >= DELTA_OFFSET_MIN_LOOPING)
catchingUp=true;
}
if (!catchingUp){ //Not catching up. Just pass through xOffset.
xOffsetLooping = xOffset;
} else if (offsetDelta == 0){ //Just caught up.
xOffsetLooping = xOffset;
catchingUp = false;
} else { //Still catching up, so use smoothed value.
xOffsetLooping = xOffsetSmooth;
}
previousOffset = xOffset;
}
示例6: handleMouseClick
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
void handleMouseClick(int screenX, int screenY) {
handleMouseMoved(screenX, screenY);
if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
inputBrush.doWithin((i, j) -> {
game.getParticleSystem().removeParticle(i, j);
});
}
if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
inputBrush.doWithin((i, j) -> {
System.out.println("brushing");
if (selected == 0) {
game.getParticleSystem().removeParticle(i, j);
} else {
game.getParticleSystem().addParticle(
new Particle(game.getPropertyDictionary().getProperties(selected), i, j)
);
}
});
}
// } else if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) {
// final float rad = new Vector2(Gdx.input.getDeltaX(), -Gdx.input.getDeltaY()).angleRad();
// final float cos = MathUtils.cos(rad);
// final float sin = MathUtils.sin(rad);
//
//// final int beginningX = (int) camera.position.x - (PARTICLE_BOARD_W / 2);
//
//// inputBrush.doWithin((i, j) -> {
//// game.velocitySystem.setXAt(5 * cos, (i - beginningX) / VCEL_W, j / VCEL_W);
//// game.velocitySystem.setYAt(5 * sin, (i - beginningX) / VCEL_W, j / VCEL_W);
//// });
// }
if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) {
final float rad = new Vector2(Gdx.input.getDeltaX(), -Gdx.input.getDeltaY()).angleRad();
final float cos = MathUtils.cos(rad);
final float sin = MathUtils.sin(rad);
final int beginningX = (int) game.getCamera().getCameraX() - (PARTICLE_BOARD_W / 2);
inputBrush.doWithin((i, j) -> {
game.getVelocitySystem().setXAt(5 * cos, (i - beginningX) / VCEL_W, j / VCEL_W);
game.getVelocitySystem().setYAt(5 * sin, (i - beginningX) / VCEL_W, j / VCEL_W);
});
}
}
示例7: polar
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
public PointF polar( float a, float l ) {
this.x = l * MathUtils.cos(a);
this.y = l * MathUtils.sin( a );
return this;
}
示例8: Flare
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
public Flare( int nRays, float radius ) {
super( 0, 0, 0, 0 );
// FIXME
// Texture is incorrectly created every time we need
// to show the effect, it must be refactored
int gradient[] = {0xFFFFFFFF, 0x00FFFFFF};
texture = new Gradient( gradient );
this.nRays = nRays;
angle = 45;
angularSpeed = 180;
vertices = ByteBuffer.
allocateDirect( (nRays * 2 + 1) * 4 * (Float.SIZE / 8) ).
order( ByteOrder.nativeOrder() ).
asFloatBuffer();
indices = ByteBuffer.
allocateDirect( nRays * 3 * Short.SIZE / 8 ).
order( ByteOrder.nativeOrder() ).
asShortBuffer();
float v[] = new float[4];
v[0] = 0;
v[1] = 0;
v[2] = 0.25f;
v[3] = 0;
vertices.put( v );
v[2] = 0.75f;
v[3] = 0;
for (int i=0; i < nRays; i++) {
float a = i * 3.1415926f * 2 / nRays;
v[0] = MathUtils.cos( a ) * radius;
v[1] = MathUtils.sin( a ) * radius;
vertices.put( v );
a += 3.1415926f * 2 / nRays / 2;
v[0] = MathUtils.cos( a ) * radius;
v[1] = MathUtils.sin( a ) * radius;
vertices.put( v );
indices.put( (short)0 );
indices.put( (short)(1 + i * 2) );
indices.put( (short)(2 + i * 2) );
}
indices.position( 0 );
}