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


Java SpriteBatch.enableBlending方法代碼示例

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


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

示例1: create

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //導入方法依賴的package包/類
@Override
public void create() {
	batch = new SpriteBatch();
	cam = new Camera(screenX, screenY);
	batch.setProjectionMatrix(cam.camera.combined);
	batch.enableBlending();
	try {
		save = new Save();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	this.setScreen(new MainMenu(this));

}
 
開發者ID:MusicDev33,項目名稱:JGame,代碼行數:17,代碼來源:JGame.java

示例2: renderGL2

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //導入方法依賴的package包/類
@Override 
public void renderGL2(float gameTime)
{
	GLCommon gl = Gdx.gl;
	gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
	
	SpriteBatch batch = getSpriteBatch();
	viewMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	batch.setProjectionMatrix(viewMatrix);
	batch.begin();
	batch.disableBlending();
	batch.setColor(Color.WHITE);
	//begin render background
	renderBackground(gameTime);
	batch.enableBlending();
	batch.end();
	gl.glEnable(GL10.GL_DEPTH_TEST);
	gl.glEnable(GL10.GL_CULL_FACE);
	camera.update();
	
	for(IDrawable3D obj : collection)
		if(obj.isVisible())
		{
			obj.renderGL2(gameTime);
		}
	gl.glDisable(GL10.GL_CULL_FACE);
	gl.glDisable(GL10.GL_DEPTH_TEST);

	batch.setProjectionMatrix(viewMatrix);
	batch.begin();
	
	//begin render foreground
	renderForeground(gameTime);
	
	//batch.enableBlending();
	//batch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
	batch.end();
}
 
開發者ID:game-libgdx-unity,項目名稱:GDX-Engine,代碼行數:39,代碼來源:BaseGameScene3D.java

示例3: render

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //導入方法依賴的package包/類
public void render(SpriteBatch batch) {
    batch.disableBlending();
    //draw opaques
    for (Map map : maps) {
        map.render(batch);
    }

    batch.enableBlending();
    //draw transparents
    player.render(batch);
    for (Slot slot : slots) {
        slot.render(batch);
    }
}
 
開發者ID:DurianHLN,項目名稱:Polymorph,代碼行數:15,代碼來源:PolyGame.java

示例4: render

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //導入方法依賴的package包/類
public void render(SpriteBatch spriteBatch) {
    generatePalettes();
    paletteTexture.bind(1);

    //Clear main framebuffer.
    Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
    Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    //Fill just the 256x240 viewport area with the current bg color
    shapeRenderer.setProjectionMatrix(camera.combined);
    shapeRenderer.begin();
    shapeRenderer.set(ShapeRenderer.ShapeType.Filled);
    shapeRenderer.setColor(bgColor);
    shapeRenderer.rect(0f, 0f, 256f, 240f);
    shapeRenderer.end();

    if (ggvm.isBackgroundVisible()) {

        sortSprites();
        //Draw foreground sprites to a separate framebuffer, where they can be
        //optionally clipped by background sprites.
        foregroundSpritesFrameBuffer.begin();
            Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
            Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
            Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
            spriteBatch.setShader(shaderProgram);
            spriteBatch.setProjectionMatrix(camera.combined);
            spriteBatch.begin();
                shaderProgram.setUniformi("u_paletteTexture", 1);
                spriteBatch.disableBlending();
                drawSprites(spriteBatch, foregroundSprites, isSprTransparentMask, foregroundSpritesCount);
            spriteBatch.end();
        foregroundSpritesFrameBuffer.end();

        viewPort.apply();
        mainFrameBuffer.begin();
            Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
            Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
            Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
            //Draw background sprites, nametable, then blend
            //the foreground sprites framebuffer to the main framebuffer.
            spriteBatch.begin();
                spriteBatch.enableBlending();
                drawSprites(spriteBatch, backgroundSprites, isBgTransparentMask, backgroundSpritesCount);
                drawNametable(ggvm, spriteBatch);
                spriteBatch.setShader(null);
                spriteBatch.draw(foregroundSpritesTextureRegion, 0, 0);
                rasterEffectManager.render(spriteBatch);
            spriteBatch.end();
        mainFrameBuffer.end();

        viewPort.apply();
        spriteBatch.begin();
            spriteBatch.draw(mainTextureRegion, 0, 0);
        spriteBatch.end();

        if (ggvm.isBackgroundClipping()) {
            shapeRenderer.setProjectionMatrix(camera.combined);
            shapeRenderer.begin();
            shapeRenderer.set(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(bgColor);
            shapeRenderer.rect(0f, 0f, 8f, 240f);
            shapeRenderer.end();
        }
    }
    fpsLogger.log();
}
 
開發者ID:gradualgames,項目名稱:ggvm,代碼行數:69,代碼來源:RenderManager.java

示例5: renderGL1

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //導入方法依賴的package包/類
@Override 
public void renderGL1(GL10 gl,float gameTime)
{
	gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
	gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	SpriteBatch batch = getSpriteBatch();
	viewMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	batch.setProjectionMatrix(viewMatrix);
	batch.begin();
	batch.disableBlending();
	//begin render background
	renderBackground(gameTime);
	
	batch.end();
	
	gl.glDisable(GL10.GL_DITHER);
	gl.glEnable(GL10.GL_DEPTH_TEST);
	gl.glEnable(GL10.GL_CULL_FACE);

	camera.update();
	camera.apply(gl);
	setLighting(gl);

	for(IDrawable3D obj : collection)
		if(obj.isVisible())
		{
			obj.renderGL1(gl, gameTime);
		}
	
	gl.glDisable(GL10.GL_CULL_FACE);
	gl.glDisable(GL10.GL_DEPTH_TEST);
	
	batch.setProjectionMatrix(viewMatrix);
	//batch.setTransformMatrix(transformMatrix);
	batch.begin();
	batch.enableBlending();
	//begin render foreground
	renderForeground(gameTime);
	
	batch.enableBlending();
	batch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
	batch.end();
}
 
開發者ID:game-libgdx-unity,項目名稱:GDX-Engine,代碼行數:44,代碼來源:BaseGameScene3D.java


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