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


Java Circle.contains方法代码示例

本文整理汇总了Java中com.badlogic.gdx.math.Circle.contains方法的典型用法代码示例。如果您正苦于以下问题:Java Circle.contains方法的具体用法?Java Circle.contains怎么用?Java Circle.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.math.Circle的用法示例。


在下文中一共展示了Circle.contains方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: isValidPosition

import com.badlogic.gdx.math.Circle; //导入方法依赖的package包/类
private boolean isValidPosition(Entity entity) {
    TransformComponent transform = entity.getComponent(TransformComponent.class);
    positionObstacle(entity);
    for (Entity player : players) {
        Circle playerBounds = (Circle) player.getComponent(CircularBoundsComponent.class).getBounds();
        if (playerBounds.radius > 0) {
            Circle spawnCircle = new Circle(playerBounds.x, playerBounds.y, playerBounds.radius + gameSettings.getPlayerNoSpawnRadius());
            if (spawnCircle.contains(transform.position.x, transform.position.y)) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:15,代码来源:World.java

示例4: apply

import com.badlogic.gdx.math.Circle; //导入方法依赖的package包/类
@Override
public void apply() {
    owner.changeSpeed(speedBoost);
    Circle c = new Circle(owner.getX(), owner.getY(), echoRange);
    for (int i = 0; i < Wave.mobs.size; i++){
        Mob m = Wave.mobs.get(i);
        if(c.contains(m.getPosition())){
            m.addEffect(new CommandFaithBuff(aoeRange, speedBoost, duration).setOwner(m));
        }
    }
    //
}
 
开发者ID:mrDarkHouse,项目名称:GDefence,代码行数:13,代码来源:CommandFaith.java

示例5: die

import com.badlogic.gdx.math.Circle; //导入方法依赖的package包/类
@Override
public boolean die(/*Tower source*/) {
    Circle dieAoe = new Circle(owner.getX(), owner.getY(), aoeRange);
    for (int i = 0; i < Wave.mobs.size; i++){
            Mob m = Wave.mobs.get(i);
        if(dieAoe.contains(m.getPosition())){
            m.addEffect(new CommandFaithBuff(aoeRange, speedBoost, duration).setOwner(m));
        }
    }
    return false;
}
 
开发者ID:mrDarkHouse,项目名称:GDefence,代码行数:12,代码来源:CommandFaith.java

示例6: attackUnarmed

import com.badlogic.gdx.math.Circle; //导入方法依赖的package包/类
/** Performs an unarmed attack targeted at a circular area directly in front
 *  of the Creature. */
public void attackUnarmed() {
    float destX = getX() + MathUtils.cos(direction) * Tile.size;
    float destY = getY() + MathUtils.sin(direction) * Tile.size;
    Circle dest = new Circle(destX, destY, getUnarmedAttackSize());
    for (Creature creature : getArea().getCreatures()) {
        if (dest.contains(creature.getX(), creature.getY())) {
            if (creature.getTeam() != getTeam()) {
                creature.dealDamage(strength);
                incrementStat(Statistic.DAMAGE_DEALT, strength);
            }
        }
    }
    getArea().getTileAt(destX, destY).dealDamage(this.strength);
}
 
开发者ID:emlai,项目名称:wge3,代码行数:17,代码来源:Creature.java

示例7: getTouchedParticle

import com.badlogic.gdx.math.Circle; //导入方法依赖的package包/类
private Particle getTouchedParticle(float x, float y) {
    Circle tapCircle = new Circle();
    for (Particle p : particles) {
        // check a slightly bigger area to allow for finger inaccuracy
        tapCircle.set(p.x, p.y, p.radius * 1.4f * camera.zoom);
        if (tapCircle.contains(x, y)) {
            return p;
        }
    }
    return null;
}
 
开发者ID:KaeruCT,项目名称:GLXY,代码行数:12,代码来源:Universe.java

示例8: hasCollisionWith

import com.badlogic.gdx.math.Circle; //导入方法依赖的package包/类
public Boolean hasCollisionWith(Poop poop){
    for (Circle circle : circles)
        if (circle.contains(poop.position))
            return true;
    return false;
}
 
开发者ID:andrkhar,项目名称:TheFreeBird,代码行数:7,代码来源:Caterpillar.java

示例9: collideWith

import com.badlogic.gdx.math.Circle; //导入方法依赖的package包/类
public boolean collideWith( Circle c ) {
	return c.contains(bottomleft) || c.contains(bottomright)|| c.contains(topleft)|| c.contains(topleft);
}
 
开发者ID:s76,项目名称:zesp2013,代码行数:4,代码来源:TmpBullet.java

示例10: collideWith

import com.badlogic.gdx.math.Circle; //导入方法依赖的package包/类
public boolean collideWith( Circle c ) {
	return  c.contains(getBottomLeft()) || c.contains(getBottomRight())|| c.contains(getTopLeft()) || c.contains(getTopRight() );
}
 
开发者ID:s76,项目名称:zesp2013,代码行数:4,代码来源:RectangleBullet.java

示例11: placeNetwork

import com.badlogic.gdx.math.Circle; //导入方法依赖的package包/类
void placeNetwork(float regionSize) {
    float iconWidth = mapIcon.getWidth() / 2;
    float iconHeight = mapIcon.getHeight() / 2;
    Circle c = new Circle(city.getPosition().x, city.getPosition().y, 1);
    Vector2 v = new Vector2();

    l1:
    for (int i = (int) ((city.getDensity() + 1) / 2 * 2500); i < 5000; i += 250) {
        c.setRadius(i / 2);

        for (int k = 0; k < 50; k++) {
            float random = (float) (Math.random() * 2 - 1);
            v.x = (float) ((Math.random() * i) - i / 2) + iconWidth;
            v.y = (float) ((Math.random() * i) - i / 2) + iconHeight;
            v.add(city.getPosition());

            if (c.contains(v)) {
                double land = Noise.getLand().getValue(v.x, 0, v.y);
                double density = Noise.DENSITY.getValue(v.x, 0, v.y);
                if (land > 0 && density >= random) {
                    break;
                }
            }

            if (k >= 50) {
                continue l1;
            }
        }
        pos = v;
        mapIcon.setPosition(v.x - iconWidth, v.y - iconHeight);

        if (v.dst2(city.getPosition()) <= City.height * City.height) {
            continue;
        }

        if (internet.getNetworkMap() == null || internet.getNetworkMap().isEmpty()) {
            break;
        }

        int j = 0;
        for (Network n : internet.getNetworkMap().values()) {
            j++;
            if (v.dst2(n.getMapIcon().getX(), n.getMapIcon().getY()) <= regionSize * regionSize && n != this) {
                continue l1;
            } else if (j >= internet.getNetworkMap().size()) {
                break l1;
            }
        }
    }
}
 
开发者ID:Rsgm,项目名称:Hakd,代码行数:51,代码来源:Network.java


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