本文整理了Java中com.badlogic.gdx.math.Rectangle.overlaps
方法的一些代码示例,展示了Rectangle.overlaps
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rectangle.overlaps
方法的具体详情如下:
包路径:com.badlogic.gdx.math.Rectangle
类名称:Rectangle
方法名:overlaps
暂无
代码示例来源:origin: libgdx/libgdx
public static boolean overlaps (Rectangle r1, Rectangle r2) {
return r1.overlaps(r2);
}
代码示例来源:origin: libgdx/libgdx
public static boolean overlaps (Rectangle r1, Rectangle r2) {
return r1.overlaps(r2);
}
代码示例来源:origin: libgdx/libgdx
/** Determines whether the given rectangles intersect and, if they do, sets the supplied {@code intersection} rectangle to the
* area of overlap.
* @return Whether the rectangles intersect */
static public boolean intersectRectangles (Rectangle rectangle1, Rectangle rectangle2, Rectangle intersection) {
if (rectangle1.overlaps(rectangle2)) {
intersection.x = Math.max(rectangle1.x, rectangle2.x);
intersection.width = Math.min(rectangle1.x + rectangle1.width, rectangle2.x + rectangle2.width) - intersection.x;
intersection.y = Math.max(rectangle1.y, rectangle2.y);
intersection.height = Math.min(rectangle1.y + rectangle1.height, rectangle2.y + rectangle2.height) - intersection.y;
return true;
}
return false;
}
代码示例来源:origin: libgdx/libgdx
/** Determines whether the given rectangles intersect and, if they do, sets the supplied {@code intersection} rectangle to the
* area of overlap.
* @return Whether the rectangles intersect */
static public boolean intersectRectangles (Rectangle rectangle1, Rectangle rectangle2, Rectangle intersection) {
if (rectangle1.overlaps(rectangle2)) {
intersection.x = Math.max(rectangle1.x, rectangle2.x);
intersection.width = Math.min(rectangle1.x + rectangle1.width, rectangle2.x + rectangle2.width) - intersection.x;
intersection.y = Math.max(rectangle1.y, rectangle2.y);
intersection.height = Math.min(rectangle1.y + rectangle1.height, rectangle2.y + rectangle2.height) - intersection.y;
return true;
}
return false;
}
代码示例来源:origin: libgdx/libgdx
@Test
public void testRectangle () {
Rectangle r1 = new Rectangle(0, 0, 1, 1);
Rectangle r2 = new Rectangle(1, 0, 2, 1);
assertTrue(r1.overlaps(r1));
assertFalse(r1.overlaps(r2));
assertTrue(r1.contains(0, 0));
}
}
代码示例来源:origin: libgdx/libgdx
private boolean isCulled () {
// we start by setting the stage coordinates to this
// actors coordinates which are relative to its parent
// Group.
float stageX = getX();
float stageY = getY();
// now we go up the hierarchy and add all the parents'
// coordinates to this actors coordinates. Note that
// this assumes that neither this actor nor any of its
// parents are rotated or scaled!
Actor parent = this.getParent();
while (parent != null) {
stageX += parent.getX();
stageY += parent.getY();
parent = parent.getParent();
}
// now we check if the rectangle of this actor in screen
// coordinates is in the rectangle spanned by the camera's
// view. This assumes that the camera has no zoom and is
// not rotated!
actorRect.set(stageX, stageY, getWidth(), getHeight());
camRect.set(camera.position.x - camera.viewportWidth / 2.0f, camera.position.y - camera.viewportHeight / 2.0f,
camera.viewportWidth, camera.viewportHeight);
visible = camRect.overlaps(actorRect);
return !visible;
}
}
代码示例来源:origin: libgdx/libgdx
koalaRect.x += koala.velocity.x;
for (Rectangle tile : tiles) {
if (koalaRect.overlaps(tile)) {
koala.velocity.x = 0;
break;
koalaRect.y += koala.velocity.y;
for (Rectangle tile : tiles) {
if (koalaRect.overlaps(tile)) {
代码示例来源:origin: libgdx/libgdx
if (viewBounds.contains(imageBounds) || viewBounds.overlaps(imageBounds)) {
final float u1 = region.getU();
final float v1 = region.getV2();
代码示例来源:origin: libgdx/libgdx
if (viewBounds.contains(imageBounds) || viewBounds.overlaps(imageBounds)) {
final float u1 = region.getU();
final float v1 = region.getV2();
代码示例来源:origin: stackoverflow.com
while(iter2.hasNext()) {
Rectangle bullet = iter2.next();
bullet.x -= 200 * Gdx.graphics.getDeltaTime();
if(bullet.x + 48 < 0) iter2.remove();
iter = meteorites.iterator();
while(iter.hasNext()) {
if(bullet.overlaps(iter.next())) {
iter2.remove();
iter.remove();
}
}
}
代码示例来源:origin: stackoverflow.com
for (Rectangle spacebarRectangle : spacebar.getSpacebarRectangles()) { // section of code
if (spacebarRectangle.overlaps(dino.getDinoRectangle())) {
spacebarSound.play();
break;
}
}
代码示例来源:origin: stackoverflow.com
dino.setOverlapping(false);
for (Rectangle spacebarRectangle : spacebar.getSpacebarRectangles()) { // section of code
if (!dino.isOverlapping() && spacebarRectangle.overlaps(dino.getDinoRectangle())) {
dino.setOverlapping(true);
spacebarSound.play();
}
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
public static boolean overlaps (Rectangle r1, Rectangle r2) {
return r1.overlaps(r2);
}
代码示例来源:origin: stackoverflow.com
if(Gdx.input.isKeyPressed(Keys.D){
float requestedX, requestedY;
//calculate the requested coordinates
Rectangle newPlayerPositionRectangle = new Rectangle(requestedX, requestedY, player.getWidth(), player.getHeight());
if (newPlayerPositionRectangle.overlaps(map) {
//move the player
} else {
//move the player only to the edge of the map and stop there
}
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** Determines whether the given rectangles intersect and, if they do, sets the supplied {@code intersection} rectangle to the
* area of overlap.
* @return Whether the rectangles intersect */
static public boolean intersectRectangles (Rectangle rectangle1, Rectangle rectangle2, Rectangle intersection) {
if (rectangle1.overlaps(rectangle2)) {
intersection.x = Math.max(rectangle1.x, rectangle2.x);
intersection.width = Math.min(rectangle1.x + rectangle1.width, rectangle2.x + rectangle2.width) - intersection.x;
intersection.y = Math.max(rectangle1.y, rectangle2.y);
intersection.height = Math.min(rectangle1.y + rectangle1.height, rectangle2.y + rectangle2.height) - intersection.y;
return true;
}
return false;
}
代码示例来源:origin: libgdx/box2dlights
protected boolean cull() {
if (!rayHandler.culling) {
culled = false;
} else {
updateBoundingRects();
culled = chainLightBounds.width > 0 &&
chainLightBounds.height > 0 &&
!chainLightBounds.overlaps(rayHandlerBounds);
}
return culled;
}
代码示例来源:origin: com.badlogicgames.box2dlights/box2dlights
protected boolean cull() {
if (!rayHandler.culling) {
culled = false;
} else {
updateBoundingRects();
culled = chainLightBounds.width > 0 &&
chainLightBounds.height > 0 &&
!chainLightBounds.overlaps(rayHandlerBounds);
}
return culled;
}
代码示例来源:origin: stackoverflow.com
public static boolean intersect(Rectangle r1, Rectangle r2, Rectangle intersection) {
if (!r1.overlaps(r2)) {
return false;
}
float x = Math.max(r1.x, r2.x);
float y = Math.max(r1.y, r2.y);
float width = Math.min(r1.x + r1.width, r2.x + r2.width) - x;
float height = Math.min(r1.y + r1.height, r2.y + r2.height) - y;
intersection.set(x, y, width, height);
return true;
}
代码示例来源:origin: jmrapp1/SpaceInvaders
public void handleCollision(WorldObject wo) {
collisionTestRect.set(desired.x, desired.y, width, height);
if (wo.getBounds().overlaps(collisionTestRect)) {
if (onCollide(wo)) {
resetLastMove();
} else if (wo instanceof AbstractEntity) {
AbstractEntity ent = (AbstractEntity) wo;
if (ent.onCollide(this)) {
ent.resetLastMove();
}
}
}
}
代码示例来源:origin: Var3D/var3dframe
/**
* r1是否在r2内
*/
public boolean isOverlaps(Actor r1, Actor r2) {
rect1.set(r1.getX(), r1.getY(), r1.getWidth(), r1.getHeight());
rect2.set(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
return rect1.overlaps(rect2);
}
内容来源于网络,如有侵权,请联系作者删除!