当前位置: 首页>>代码示例>>Java>>正文


Java SpriteBatch.createDefaultShader方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader方法的典型用法代码示例。如果您正苦于以下问题:Java SpriteBatch.createDefaultShader方法的具体用法?Java SpriteBatch.createDefaultShader怎么用?Java SpriteBatch.createDefaultShader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.g2d.SpriteBatch的用法示例。


在下文中一共展示了SpriteBatch.createDefaultShader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
final void init() {
	if(spriteBatchDefault == null) {
		spriteBatchDefault = SpriteBatch.createDefaultShader();
	}
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:6,代码来源:GLProgramCache.java

示例2: CircularProgress

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
public CircularProgress(TextureRegion region) {
    this.region = region;

    /**
     *  使用默认的shader
     *  一般不指定ShaderProgram,我们使用SpriteBatch的时候都是使用默认的shader
     */
    this.shader = SpriteBatch.createDefaultShader();
    
    // 设置顶点数据类型为数组类型
    Mesh.VertexDataType vertexDataType = Mesh.VertexDataType.VertexArray;
    
    /**
     * 只需要处理 :顶点坐标、颜色、纹理坐标 
     */
    VertexAttribute[] vertexAttributes = new VertexAttribute[3];
    vertexAttributes[0] = new VertexAttribute(Usage.Position, POSITION_COMPONENTS, "a_position");
    vertexAttributes[1] = new VertexAttribute(Usage.ColorPacked, COLOR_COMPONENTS, "a_color");
    vertexAttributes[2] = new VertexAttribute(Usage.TextureCoordinates, TEXCOORD_COMPONENTS, "a_texCoord0");
    
    this.mesh = new Mesh(vertexDataType, false, MAX_VERTICES, MAX_INDICES, vertexAttributes);
    float width = region.getRegionWidth();
    float height = region.getRegionHeight();
    
    /**
     * 初始化顶点数据
     */
    vertices = new float[MAX_VERTICES  * TOTAL_COMPONENTS];

    int idx = 0; 
    vertices[(idx++)] = 0;
    vertices[(idx++)] = 0;

    idx = idx + 3; 
    vertices[(idx++)] = 0;
    vertices[(idx++)] = (height / 2.0f);

    idx = idx + 3;
    vertices[(idx++)] = (width / 2.0f);
    vertices[(idx++)] = (height / 2.0f);

    idx = idx + 3;
    vertices[(idx++)] = (width / 2.0f);
    vertices[(idx++)] = 0;

    idx = idx + 3;
    vertices[(idx++)] = (width / 2.0f);
    vertices[(idx++)] = (-height / 2.0f);

    idx = idx + 3;
    vertices[(idx++)] = 0;
    vertices[(idx++)] = (-height / 2.0f);

    idx = idx + 3; 
    vertices[(idx++)] = (-width / 2.0f);
    vertices[(idx++)] = (-height / 2.0f);

    idx = idx + 3; 
    vertices[(idx++)] = (-width / 2.0f);
    vertices[(idx++)] = 0;

    idx = idx + 3; 
    vertices[(idx++)] = (-width / 2.0f);
    vertices[(idx++)] = (height / 2.0f);
   
    /**
     * 初始话顶点位置 与 纹理坐标
     */
    for (int i = 0; i < 9; i++) {
        vertices[i * 5 + 0] = (vertices[i * 5] + (width / 2.0f));
        vertices[i * 5 + 1] = (vertices[i * 5 + 1] + (height / 2.0f));
        Vector2 uv = getUV(region, vertices[i * 5], vertices[i * 5 + 1]);
        vertices[i * 5 + 3] = uv.x;
        vertices[i * 5 + 4] = uv.y;
        
    }
    
    
}
 
开发者ID:cn-s3bit,项目名称:TH902,代码行数:80,代码来源:CircularProgress.java


注:本文中的com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。