当前位置: 首页>>代码示例>>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;未经允许,请勿转载。