當前位置: 首頁>>代碼示例>>Java>>正文


Java Array.toArray方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.utils.Array.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java Array.toArray方法的具體用法?Java Array.toArray怎麽用?Java Array.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.utils.Array的用法示例。


在下文中一共展示了Array.toArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ConsoleCommand

import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
/**
 * @param str the whole string of the command, including identifier and arguments all separated by whitespaces
 */
public ConsoleCommand(String str) {
    String[] splitBuf = str.split(" ");
    this.command = splitBuf[0];
    if (splitBuf.length <= 1) {
        this.args = new String[]{};
    } else {
        Array<String> arr = new Array<String>();
        for (String s : splitBuf) {
            if (! s.equals(splitBuf[0])) arr.add(s);
        }
        this.args = arr.toArray(String.class);
    }
}
 
開發者ID:Benjozork,項目名稱:Onyx,代碼行數:17,代碼來源:ConsoleCommand.java

示例2: FlexBatch

import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
/**
 * Construct a FlexBatch capable of drawing the given Batchable type and other compatible Batchables (ones with the same + *
 * VertexAttributes or subset of beginning VertexAttributes). The FlexBatch will not be limited to FixedSizeBatchables.
 *
 * @param batchableType The type of Batchable that defines the VertexAttributes supported by this FlexBatch, and the + *
 *                      default Batchable type drawn by the {@link #draw()} method.
 * @param maxVertices   The number of vertices this FlexBatch can batch at once. Maximum of 32767. If the Batchable is a
 *                      FixedSizeBatchable and 0 is used for maxTriangles, this value will be rounded down to a multiple of the
 *                      Batchable's size.
 * @param maxTriangles  The number of triangles this FlexBatch can batch at once, or 0 to optimize this FlexBatch to draw only
 *                      FixedSizeBatchables.
 */
public FlexBatch (Class<T> batchableType, int maxVertices, int maxTriangles) {
    // 32767 is max vertex index.
    if (maxVertices > 32767)
        throw new IllegalArgumentException("Can't have more than 32767 vertices per batch: " + maxTriangles);
    if (Modifier.isAbstract(batchableType.getModifiers()))
        throw new IllegalArgumentException("Can't use an abstract batchableType");

    this.batchableType = batchableType;

    try {
        internalBatchable = batchableType.newInstance();
    } catch (Exception e) {
        throw new IllegalArgumentException("Batchable classes must be public and have an empty constructor.", e);
    }

    Array<VertexAttribute> attributesArray = new Array<VertexAttribute>(true, 10, VertexAttribute.class);
    internalBatchable.addVertexAttributes(attributesArray);
    VertexAttributes vertexAttributes = new VertexAttributes(attributesArray.toArray());
    attributeOffsets = new AttributeOffsets(vertexAttributes);
    vertexSize = vertexAttributes.vertexSize / 4;
    final int vertexArraySize = vertexSize * maxVertices;
    vertices = new float[vertexArraySize];
    fixedIndices = internalBatchable instanceof FixedSizeBatchable && maxTriangles == 0;

    if (fixedIndices) {
        FixedSizeBatchable fixedSizeBatchable = (FixedSizeBatchable) internalBatchable;
        verticesPerBatchable = fixedSizeBatchable.getVerticesPerBatchable();
        vertexDataPerBatchable = verticesPerBatchable * vertexSize;
        this.maxVertices = maxVertices - (maxVertices % verticesPerBatchable);
        this.maxIndices = (this.maxVertices / verticesPerBatchable) * fixedSizeBatchable.getTrianglesPerBatchable() * 3;
        indicesPerBatchable = fixedSizeBatchable.getTrianglesPerBatchable() * 3;
        triangles = new short[maxIndices];
        fixedSizeBatchable.populateTriangleIndices(triangles);
    } else {
        if (maxTriangles == 0) throw new IllegalArgumentException(
                "maxTriangles must be greater than 0 if batchableType is not a FixedSizeBatchable");
        this.maxVertices = maxVertices;
        maxIndices = maxTriangles * 3;
        triangles = new short[maxIndices];
        indicesPerBatchable = verticesPerBatchable = vertexDataPerBatchable = 0;
    }

    Mesh.VertexDataType vertexDataType = Gdx.gl30 != null ? VertexDataType.VertexBufferObjectWithVAO
            : Mesh.VertexDataType.VertexArray;
    mesh = new Mesh(vertexDataType, false, this.maxVertices, maxIndices, attributesArray.toArray());
    if (fixedIndices) mesh.setIndices(triangles);

    textureUnitUniforms = new String[internalBatchable.getNumberOfTextures()];
    for (int i = 0; i < textureUnitUniforms.length; i++) {
        ;
        textureUnitUniforms[i] = "u_texture" + i;
    }

    projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    renderContext = new RenderContextAccumulator();
    renderContext.setBlending(true);
    renderContext.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:72,代碼來源:FlexBatch.java


注:本文中的com.badlogic.gdx.utils.Array.toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。