本文整理汇总了Java中com.badlogic.gdx.utils.FloatArray.clear方法的典型用法代码示例。如果您正苦于以下问题:Java FloatArray.clear方法的具体用法?Java FloatArray.clear怎么用?Java FloatArray.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.FloatArray
的用法示例。
在下文中一共展示了FloatArray.clear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFlatPixelArray
import com.badlogic.gdx.utils.FloatArray; //导入方法依赖的package包/类
public float[] getFlatPixelArray() {
FloatArray floats = new FloatArray();
flatPixelArray = new float[width * height * 3];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
float r = pixels[y][x][0];
float g = pixels[y][x][1];
float b = pixels[y][x][2];
floats.addAll(r, g, b);
}
}
for (int i = 0; i < floats.size; i++) {
flatPixelArray[i] = floats.get(i);
}
floats.clear();
return flatPixelArray;
}
示例2: debugRender
import com.badlogic.gdx.utils.FloatArray; //导入方法依赖的package包/类
/** Draws a polygon, using ray start and end points as vertices */
public void debugRender (PolygonShapeRenderer shapeRenderer) {
shapeRenderer.setColor(Color.BLUE);
FloatArray vertices = Pools.obtain(FloatArray.class);
vertices.clear();
for (int i = 0; i < rayNum; i++) {
vertices.addAll(mx[i], my[i]);
}
for (int i = rayNum - 1; i > -1; i--) {
vertices.addAll(startX[i], startY[i]);
}
vertices.add(vertices.get(0));
vertices.add(vertices.get(1));
shapeRenderer.polyline(vertices.shrink());
Pools.free(vertices);
}
示例3: intersectSegments
import com.badlogic.gdx.utils.FloatArray; //导入方法依赖的package包/类
/** @param segments the segments
* @param polygon if the segments represent a closed polygon
* @param intersections the array to store the intersections in */
public static void intersectSegments(float x1, float y1, float x2, float y2, float[] segments, boolean polygon, FloatArray intersections) {
if(polygon && segments.length < 6)
throw new IllegalArgumentException("a polygon consists of at least 3 points: " + segments.length);
else if(segments.length < 4)
throw new IllegalArgumentException("segments does not contain enough vertices to represent at least one segment: " + segments.length);
if(segments.length % 2 != 0)
throw new IllegalArgumentException("malformed segments; the number of vertices is not dividable by 2: " + segments.length);
intersections.clear();
Vector2 tmp = Pools.obtain(Vector2.class);
for(int i = 0, n = segments.length - (polygon ? 0 : 2); i < n; i += 2) {
float x3 = segments[i], y3 = segments[i + 1], x4 = wrapIndex(i + 2, segments), y4 = wrapIndex(i + 3, segments);
if(Intersector.intersectSegments(x1, y1, x2, y2, x3, y3, x4, y4, tmp)) {
intersections.add(tmp.x);
intersections.add(tmp.y);
}
}
Pools.free(tmp);
}
示例4: debugRender
import com.badlogic.gdx.utils.FloatArray; //导入方法依赖的package包/类
/**
* Draws a polygon, using ray start and end points as vertices
*/
public void debugRender(ShapeRenderer shapeRenderer) {
shapeRenderer.setColor(Color.YELLOW);
FloatArray vertices = Pools.obtain(FloatArray.class);
vertices.clear();
for (int i = 0; i < rayNum; i++) {
vertices.addAll(mx[i], my[i]);
}
for (int i = rayNum - 1; i > -1; i--) {
vertices.addAll(startX[i], startY[i]);
}
shapeRenderer.polygon(vertices.shrink());
Pools.free(vertices);
}
示例5: contains
import com.badlogic.gdx.utils.FloatArray; //导入方法依赖的package包/类
@Override
public boolean contains(float x, float y) {
// fast fail
if (!this.chainLightBounds.contains(x, y))
return false;
// actual check
FloatArray vertices = Pools.obtain(FloatArray.class);
vertices.clear();
for (int i = 0; i < rayNum; i++) {
vertices.addAll(mx[i], my[i]);
}
for (int i = rayNum - 1; i > -1; i--) {
vertices.addAll(startX[i], startY[i]);
}
int intersects = 0;
for (int i = 0; i < vertices.size; i += 2) {
float x1 = vertices.items[i];
float y1 = vertices.items[i + 1];
float x2 = vertices.items[(i + 2) % vertices.size];
float y2 = vertices.items[(i + 3) % vertices.size];
if (((y1 <= y && y < y2) || (y2 <= y && y < y1)) &&
x < ((x2 - x1) / (y2 - y1) * (y - y1) + x1))
intersects++;
}
boolean result = (intersects & 1) == 1;
Pools.free(vertices);
return result;
}
示例6: contains
import com.badlogic.gdx.utils.FloatArray; //导入方法依赖的package包/类
@Override
public boolean contains (float x, float y) {
// fast fail
if (!this.chainLightBounds.contains(x, y))
return false;
// actual check
FloatArray vertices = Pools.obtain(FloatArray.class);
vertices.clear();
for (int i = 0; i < rayNum; i++) {
vertices.addAll(mx[i], my[i]);
}
for (int i = rayNum - 1; i > -1; i--) {
vertices.addAll(startX[i], startY[i]);
}
int intersects = 0;
for (int i = 0; i < vertices.size; i += 2) {
float x1 = vertices.items[i];
float y1 = vertices.items[i + 1];
float x2 = vertices.items[(i + 2) % vertices.size];
float y2 = vertices.items[(i + 3) % vertices.size];
if (((y1 <= y && y < y2) || (y2 <= y && y < y1)) && x < ((x2 - x1) / (y2 - y1) * (y - y1) + x1))
intersects++;
}
boolean result = (intersects & 1) == 1;
Pools.free(vertices);
return result;
}
示例7: computeGlyphAdvancesAndPositions
import com.badlogic.gdx.utils.FloatArray; //导入方法依赖的package包/类
public void computeGlyphAdvancesAndPositions(CharSequence paramCharSequence, FloatArray paramFloatArray1, FloatArray paramFloatArray2)
{
paramFloatArray1.clear();
paramFloatArray2.clear();
int i = paramCharSequence.length();
Object localObject1 = null;
float f5;
int k;
Object localObject3;
if (this.data.scaleX == 1.0F)
{
f5 = 0.0F;
k = 0;
if (k < i)
{
char c2 = paramCharSequence.charAt(k);
localObject3 = this.data.getGlyph(c2);
if (localObject3 == null)
break label277;
if (localObject1 != null)
f5 += localObject1.getKerning(c2);
paramFloatArray1.add(((BitmapFont.Glyph)localObject3).xadvance);
paramFloatArray2.add(f5);
}
}
for (float f6 = f5 + ((BitmapFont.Glyph)localObject3).xadvance; ; f6 = f5)
{
k++;
f5 = f6;
localObject1 = localObject3;
break;
paramFloatArray1.add(0.0F);
paramFloatArray2.add(f5);
return;
float f1 = this.data.scaleX;
float f2 = 0.0F;
int j = 0;
Object localObject2;
float f4;
if (j < i)
{
char c1 = paramCharSequence.charAt(j);
localObject2 = this.data.getGlyph(c1);
if (localObject2 == null)
break label266;
if (localObject1 != null)
f2 += f1 * localObject1.getKerning(c1);
f4 = f1 * ((BitmapFont.Glyph)localObject2).xadvance;
paramFloatArray1.add(f4);
paramFloatArray2.add(f2);
}
for (float f3 = f4 + f2; ; f3 = f2)
{
j++;
f2 = f3;
localObject1 = localObject2;
break;
paramFloatArray1.add(0.0F);
paramFloatArray2.add(f2);
return;
label266: localObject2 = localObject1;
}
label277: localObject3 = localObject1;
}
}