Game Development Reference
In-Depth Information
return ((hits & 1) != 0);
}
@Override
public String toString() {
if (npoints == 0)
return null;
String s = ""; //
for (int i = 0; i < xpoints.length; i++) {
s += "(" + xpoints[i] + "," + ypoints[i] + ") ";
}
return s;
}
/**
* Get polygon points (x0y0, x1y1,.....) for rendering Each point pair will
* render 1 line so the total # of points must be num sides * 4
*
* @return
*/
public float[] getPoints() {
int size = npoints * 4;
float[] points = new float[size];
int j = 1;
if (size == 0 || xpoints == null || ypoints == null)
return null;
points[0] = xpoints[0];
points[1] = ypoints[0];
for (int i = 2; i < points.length - 2; i += 4) {
points[i] = xpoints[j];
points[i + 1] = ypoints[j];
points[i + 2] = xpoints[j];
points[i + 3] = ypoints[j];
j++;
}
points[size - 2] = xpoints[0];
points[size - 1] = ypoints[0];
return points;
}
}
Search WWH ::




Custom Search