Example usage for com.badlogic.gdx.math.collision Sphere overlaps

List of usage examples for com.badlogic.gdx.math.collision Sphere overlaps

Introduction

In this page you can find the example usage for com.badlogic.gdx.math.collision Sphere overlaps.

Prototype

public boolean overlaps(Sphere sphere) 

Source Link

Usage

From source file:com.game.HelloWorld.java

License:Apache License

private boolean isOnThePlayer(int x, int y) {

    float fingerX = x, fingerY = Gdx.graphics.getHeight() - y;
    float playerX = Gdx.graphics.getWidth() / 2, playerY = Gdx.graphics.getHeight() / 2;

    Sphere sphereFinger = new Sphere(new Vector3(fingerX, fingerY, 0), 40);
    Sphere spherePlayer = new Sphere(new Vector3(playerX, playerY, 0), 40);
    if (sphereFinger.overlaps(spherePlayer)) {
        isOnThePlayer = true;/*from  w  w w. j av  a 2  s .co  m*/
        return true;
    } else {
        isOnThePlayer = false;
        return false;
    }
}

From source file:com.game.HelloWorld.java

License:Apache License

private boolean isCollision(int x, int y) {
    Sphere sphere = new Sphere(new Vector3(x, y, 0), 50);

    Iterator<Sphere> itr = positionBoites.iterator();
    while (itr.hasNext()) {
        Sphere element = itr.next();
        if (element.overlaps(sphere))
            return true;
    }//from  w  ww.j  a v a 2s.c  om

    return false;
}