本文整理汇总了Java中com.badlogic.gdx.math.Circle类的典型用法代码示例。如果您正苦于以下问题:Java Circle类的具体用法?Java Circle怎么用?Java Circle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Circle类属于com.badlogic.gdx.math包,在下文中一共展示了Circle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: splitCollision
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
public int splitCollision(float x, float y) {
Circle touchCircle = new Circle();
touchCircle.radius = 5f;
touchCircle.setPosition(x, y);
if(touchCircle.contains(splitPositions[0], touchCircle.y)) {
return 0;
}
if(touchCircle.contains(splitPositions[1], touchCircle.y)) {
return 1;
}
if(touchCircle.contains(touchCircle.x, splitPositions[2])) {
return 2;
}
if(touchCircle.contains(touchCircle.x, splitPositions[3])) {
return 3;
}
return -1;
}
示例2: initBall
import com.badlogic.gdx.math.Circle; //导入依赖的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();
}
示例3: Caterpillar
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
public Caterpillar(ShapeRenderer renderer, Vector2 position,boolean facingRight) {
super(renderer, position, facingRight);
float x = position.x - 4 *CATERPILLAR_TIGHT_RADIUS;
float y = position.y;
circles = new Array<Circle>();
for ( int i = 0 ; i< CATERPILLAR_CIRCLES_NUMBER; i++) {
circles.add(new Circle(x, y, CATERPILLAR_RADIUS));
x += 2 * CATERPILLAR_TIGHT_RADIUS;
}
if (facingRight) {
velocity.set(CATERPILLAR_SPEED_X, 0f);
}
else{
velocity.set(-CATERPILLAR_SPEED_X, 0f);
}
nanotimeAnimationStart = TimeUtils.nanoTime();
eye = new Vector2();
}
示例4: Cat
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
public Cat(ShapeRenderer renderer, Boolean facingRight) {
super(renderer, new Vector2(), facingRight);
if (facingRight) {
position.set(CAT_START_X_LEFT, CAT_Y);
velocity.set(CAT_SPEED_X, 0f);
}
else{
position.set(CAT_START_X_RIGHT, CAT_Y);
velocity.set(-CAT_SPEED_X, 0f);
}
catCreateMillis = TimeUtils.millis();
circle = new Circle(0,0, CAT_HEAD_RADIUS);
rectangle = new Rectangle(0,0, CAT_BODY_LENGTH, CAT_BODY_WIDTH);
update(0);
}
示例5: getPositionFromMapObject
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
private Vector2 getPositionFromMapObject(MapObject mapObject) {
if (mapObject instanceof PolygonMapObject) {
Polygon polygon = ((PolygonMapObject) mapObject).getPolygon();
return new Vector2(polygon.getX(), polygon.getY());
} else if (mapObject instanceof RectangleMapObject) {
Rectangle rectangle = ((RectangleMapObject) mapObject).getRectangle();
return new Vector2(rectangle.getX(), rectangle.getY());
} else if (mapObject instanceof EllipseMapObject) {
Ellipse ellipse = ((EllipseMapObject) mapObject).getEllipse();
return new Vector2(ellipse.x, ellipse.y);
} else if (mapObject instanceof CircleMapObject) {
Circle circle = ((CircleMapObject) mapObject).getCircle();
return new Vector2(circle.x, circle.y);
}
throw new GdxRuntimeException("Only Polygons, Rectangles, Ellipses and Circles are supported!");
}
示例6: execute
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
@Override
public void execute(float deltatime) {
CoreEntity ball = _context.getBallEntity();
Circle ballShape = (Circle) ball.getView().shape;
Motion motion = ball.getMotion();
for (CoreEntity e : _groupPlayer.getEntities()) {
Player player = e.getPlayer();
Score score = e.getScore();
if (ballShape.x + ballShape.radius <= -(WIDTH / 2) && player.id == Player.ID.PLAYER2)
restart(ballShape, motion, score);
if (ballShape.x - ballShape.radius >= (WIDTH / 2) && player.id == Player.ID.PLAYER1)
restart(ballShape, motion, score);
}
}
示例7: execute
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
@Override
public void execute(float deltatime) {
CoreEntity ball = _context.getBallEntity();
Circle ballShape = (Circle) ball.getView().shape;
Motion ballMotion = ball.getMotion();
if (ballShape.y - ballShape.radius <= -(Pong.SCREEN_HEIGHT / 2)) {
ballShape.setY(-(Pong.SCREEN_HEIGHT / 2) + ballShape.radius);
ballMotion.velocity.y = -(ballMotion.velocity.y + 10);
ballMotion.velocity.x = ballMotion.velocity.x + 10;
}
if (ballShape.y + ballShape.radius >= (Pong.SCREEN_HEIGHT / 2)) {
ballShape.setY((Pong.SCREEN_HEIGHT / 2) - ballShape.radius);
ballMotion.velocity.y = -(ballMotion.velocity.y + 10);
ballMotion.velocity.x = ballMotion.velocity.x + 10;
}
for (CoreEntity e : _group.getEntities()) {
View view = e.getView();
circleRectCollision(ballShape, (Rectangle) view.shape, ballMotion);
}
}
示例8: execute
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
@Override
public void execute(float deltatime) {
for (CoreEntity e : _group.getEntities()) {
Motion motion = e.getMotion();
View view = e.getView();
if (view.shape instanceof Rectangle) {
Rectangle ret = (Rectangle) view.shape;
ret.setPosition(ret.x + motion.velocity.x * Gdx.graphics.getDeltaTime(),
ret.y + motion.velocity.y * Gdx.graphics.getDeltaTime());
} else {
Circle circle = (Circle) view.shape;
circle.setPosition(circle.x + motion.velocity.x * Gdx.graphics.getDeltaTime()
, circle.y + motion.velocity.y * Gdx.graphics.getDeltaTime());
}
}
}
示例9: areColliding
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
private boolean areColliding(Rectangle rectangle, Circle circle) {
// TODO: Complete this function!
boolean containsACorner = circle.contains(rectangle.x, rectangle.y) || // Bottom left
circle.contains(rectangle.x + rectangle.width, rectangle.y) || // Bottom right
circle.contains(rectangle.x + rectangle.width, rectangle.y + rectangle.height) || // Top Right
circle.contains(rectangle.x, rectangle.y + rectangle.height); // Top left
boolean inHorizontalInterval = rectangle.x < circle.x && circle.x < rectangle.x + rectangle.width;
boolean inVerticalInterval = rectangle.y < circle.y && circle.y < rectangle.y + rectangle.height;
boolean inHorizontalNeighborhood = rectangle.x - circle.radius < circle.x && circle.x < rectangle.x + rectangle.width + circle.radius;
boolean inVerticalNeighborhood = rectangle.y - circle.radius < circle.y && circle.y < rectangle.y + rectangle.height + circle.radius;
boolean touchingAnEdge = inHorizontalInterval && inVerticalNeighborhood ||
inHorizontalNeighborhood && inVerticalInterval;
return containsACorner || touchingAnEdge;
}
示例10: Meteorite
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
public Meteorite(float x, float y, float scrollSpeed) {
super(x, y, 0, 0, scrollSpeed);
meteor= new Circle();
//alfa = new Random();
altura = new Random();
radius=new Random();
//increm = (float)((alfa.nextInt(4000)-2000)/1000);
/* if((int)increm==0)
this.height = altura.nextInt(100);
else if((int)increm==-1)
this.height = altura.nextInt(50)-50;
else if((int)increm==1)
this.height = altura.nextInt(50)+50;
else
this.height = altura.nextInt(100);
*/
this.height = altura.nextInt(100);
this.width = radius.nextInt(15)+5;
}
示例11: PhysicalObject
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
public PhysicalObject(float x, float y, float offsetX, float offsetY, String textureName, IRTSMap map) {
super(x, y);
this.map = map;
this.shapeRenderer = RTSGame.game.cameraShapeRenderer;
this.textureName = textureName;
this.spriteOffsetX = offsetX;
this.spriteOffsetY = offsetY;
initGraphics();
initHardRadius(height / 2f);
// Default soft radius of 5
softRadius = new Circle(x, y, 10);
// Default shadow
shadowA = 15f;
shadowB = 4f;
// Add to map, just once (these entities do not move)
map.updateEntity(this);
}
示例12: ThirdScreen
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
public ThirdScreen (Game agame) {
game = agame;
batch = new SpriteBatch();
img = new Texture("aklu.jpg");
shapeRenderer = new ShapeRenderer();
centerCircle = new Circle();
leftCircle = new Circle();
rightCircle = new Circle();
myTouch = new Circle();
camera = new OrthographicCamera();
camera.setToOrtho(false, 800, 400);
colorChanger = 0;
counter = 0;
}
示例13: secondScreen
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
public secondScreen (Game agame) {
game = agame;
batch = new SpriteBatch();
img = new Texture("aklu.jpg");
shapeRenderer = new ShapeRenderer();
centerCircle = new Circle();
leftCircle = new Circle();
rightCircle = new Circle();
myTouch = new Circle();
camera = new OrthographicCamera();
camera.setToOrtho(false, 800, 400);
colorChanger = 0;
counter = 0;
}
示例14: create
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
@Override
public void create () {
batch = new SpriteBatch();
img = new Texture("aklu.jpg");
shapeRenderer = new ShapeRenderer();
centerCircle = new Circle();
leftCircle = new Circle();
rightCircle = new Circle();
myTouch = new Circle();
camera = new OrthographicCamera();
camera.setToOrtho(false, 800, 400);
colorChanger = 0;
}
示例15: overlaps
import com.badlogic.gdx.math.Circle; //导入依赖的package包/类
public boolean overlaps(BoundsComponent other) {
if (getBounds() instanceof Rectangle && other.getBounds() instanceof Rectangle) {
return Intersector.overlaps((Rectangle) getBounds(), (Rectangle) other.getBounds());
} else if (getBounds() instanceof Circle && other.getBounds() instanceof Circle) {
return Intersector.overlaps((Circle) getBounds(), (Circle) other.getBounds());
} else if (getBounds() instanceof Circle && other.getBounds() instanceof Rectangle) {
return Intersector.overlaps((Circle) getBounds(), (Rectangle) other.getBounds());
} else if (getBounds() instanceof Rectangle && other.getBounds() instanceof Circle) {
return Intersector.overlaps((Circle) other.getBounds(), (Rectangle) getBounds());
}
throw new RuntimeException("Cannot compare " + this.getBounds() + " and " + other.getBounds());
}