當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。