本文整理汇总了Java中com.badlogic.gdx.math.MathUtils.cos方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.cos方法的具体用法?Java MathUtils.cos怎么用?Java MathUtils.cos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.MathUtils
的用法示例。
在下文中一共展示了MathUtils.cos方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
});
}
}
示例3: 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;
}
示例4: 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 );
}