当前位置: 首页>>代码示例>>Java>>正文


Java Circle类代码示例

本文整理汇总了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;
}
 
开发者ID:whitecostume,项目名称:libgdx_ui_editor,代码行数:21,代码来源:EditingZone.java

示例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();
}
 
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:24,代码来源:Balanceball.java

示例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();
}
 
开发者ID:andrkhar,项目名称:TheFreeBird,代码行数:23,代码来源:Caterpillar.java

示例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);
    }
 
开发者ID:andrkhar,项目名称:TheFreeBird,代码行数:20,代码来源:Cat.java

示例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!");
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:17,代码来源:GameMapLoader.java

示例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);

    }

}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:20,代码来源:BoundsSystem.java

示例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);
    }

}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:26,代码来源:ContactSystem.java

示例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());
        }
    }
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:18,代码来源:MoveSystem.java

示例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;
    }
 
开发者ID:udacity,项目名称:ud406,代码行数:21,代码来源:RectangleCircleCollisionScreen.java

示例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;
    
    
    
}
 
开发者ID:CODA-Masters,项目名称:Little-Nibolas,代码行数:25,代码来源:Meteorite.java

示例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);
   }
 
开发者ID:langurmonkey,项目名称:rts-engine,代码行数:22,代码来源:PhysicalObject.java

示例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;
}
 
开发者ID:alaskalinuxuser,项目名称:apps_small,代码行数:15,代码来源:ThirdScreen.java

示例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;

}
 
开发者ID:alaskalinuxuser,项目名称:apps_small,代码行数:16,代码来源:secondScreen.java

示例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;
}
 
开发者ID:alaskalinuxuser,项目名称:apps_small,代码行数:14,代码来源:MyGdxGame.java

示例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());
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:13,代码来源:BoundsComponent.java


注:本文中的com.badlogic.gdx.math.Circle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。