gdx2d
gdx2d copied to clipboard
Polygonclass stinks
The class from Nils is a total mess and not complete. For instance, the contains
method does not work etc... This class should be replace by the libgdx supporting classes such as Rectangle and Polygon from com.badlogic.gdx.math
.Rectangle and com.badlogic.gdx.math.Polygon
In addition, some infos from a student:
Bonjour,
la classe Polygon
du package hevs.gdx2d.components.graphics
n'est pas finie et le méthode de translation n'existe pas(voir entête). Je veux bien créer une nouvelle classe qui hérite de celle-ci et rajouté les méthodes manquantes, mais je ne sais pas comment procédé avec l'attribut vectorList
, qui n'est pas initialisé, mais qui est appelé dans la fonction public boolean contains(Vector2 p)
.
This is dead code: https://github.com/hevs-isi/gdx2d/blob/master/gdx2d-library/gdx2d-core/src/main/java/ch/hevs/gdx2d/components/graphics/Polygon.java#L74
Maybe I missed something but the vectorList
is always null.
Temporary fix :
class PolygonWorking extends Polygon{
public PolygonWorking(Vector2[] points) {
super(points);
}
@Override
public boolean contains(Vector2 p) {
Vector2[] v = Polygon.float2vec2(this.getVertices());
Array<Vector2> a = Array.with(v);
return Intersector.isPointInPolygon(a, p);
}
}