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


Java Batch.setColor方法代碼示例

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


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

示例1: drawBg

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
public void drawBg(Batch batch, float parentAlpha) {
    batch.end();
    Gdx.gl.glLineWidth(1.0f);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
    Matrix4 matrix = batch.getTransformMatrix();
    shapeRenderer.setTransformMatrix(matrix);

    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    BG.a = parentAlpha;
    shapeRenderer.setColor(BG);
    shapeRenderer.rect(getX(), getY(), getWidth(), getHeight());
    shapeRenderer.end();

    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
    batch.setColor(Color.WHITE.r, Color.WHITE.g, Color.WHITE.b, Color.WHITE.a * parentAlpha);
}
 
開發者ID:whitecostume,項目名稱:libgdx_ui_editor,代碼行數:21,代碼來源:EditingZone.java

示例2: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
    Color color = getColor();
    if (hidden) {
        color = Color.DARK_GRAY;
    } else if (selected) {
        color = Assets.select(color);
    } else if (hovered) {
        color = Assets.highlight(color);
    }

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    if (hidden) {
        batch.draw(Assets.FOGGY, getX(), getY(), getWidth(), getHeight());
    } else {
        batch.draw(texture, getX(), getY(), getWidth(), getHeight());
    }

    if (city != null) {
        city.draw(batch, parentAlpha);
    }
}
 
開發者ID:conquest,項目名稱:conquest,代碼行數:23,代碼來源:Tile.java

示例3: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
    final float x = getX(), y = getY();

    batch.setColor(theme.background);
    batch.draw(background, x, y, getWidth(), getHeight());

    // Avoid drawing on the borders by adding +1 cell padding
    for (int i = 0; i < colorsUsed.length; ++i) {
        for (int j = 0; j < colorsUsed[i].length; ++j) {
            Cell.draw(theme.cellTexture, theme.getCellColor(colorsUsed[i][j]), batch,
                    x + cellSize * (j + 1), y + cellSize * (i + 1), cellSize);
        }
    }

    super.draw(batch, parentAlpha);
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:18,代碼來源:ThemeCard.java

示例4: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
    final float x = getX(), y = getY();

    batch.setColor(Klooni.theme.background);
    batch.draw(background, x, y, getWidth(), getHeight());

    // Avoid drawing on the borders by adding +1 cell padding
    board.pos.set(x + cellSize * 1, y + cellSize * 1);

    // Draw only if effects are done, i.e. not showcasing
    if (board.effectsDone())
        board.draw(batch);

    super.draw(batch, parentAlpha);
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:17,代碼來源:EffectCard.java

示例5: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
public void draw (Batch batch, float parentAlpha) {
	validate();

	Color color = getColor();
	batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);

	float x = getX();
	float y = getY() + floatAction.getValue();
	float scaleX = getScaleX();
	float scaleY = getScaleY();

	if (drawable instanceof TransformDrawable) {
		float rotation = getRotation();
		if (scaleX != 1 || scaleY != 1 || rotation != 0) {
			((TransformDrawable)drawable).draw(batch, x + imageX, y + imageY, getOriginX() - imageX, getOriginY() - imageY,
				imageWidth, imageHeight, scaleX, scaleY, rotation);
			return;
		}
	}
	if (drawable != null) drawable.draw(batch, x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
}
 
開發者ID:raeleus,項目名稱:bobbybird,代碼行數:22,代碼來源:BouncingImage.java

示例6: render

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void render(Batch batch, float deltaTime)
{
    if (body == null) return;

    Color oldColor = batch.getColor();

    batch.setColor(1f, (health + 5)/10f, (health + 5)/10f, 1f);

    Vector2 pos = body.getPosition();
    pos.scl(Physics.PPM);

    float scaleX = 1f;

    animationTime += deltaTime;


    batch.draw(rabbit,                                      // TextureRegion (front, back, side)
            pos.x - rabbit.getRegionWidth() / 2,           // Offset to the X position (character center)
            pos.y,                                          // Y position is at the foots
            rabbit.getRegionWidth() / 2,                   // Origin X (important for flipping)
            rabbit.getRegionHeight(),                      // Origin Y
            rabbit.getRegionWidth(),                       // Width
            rabbit.getRegionHeight(),                      // Height
            scaleX,                                         // Scale X (-1 to flip)
            1f,                                             // Scale Y
            0f);                                            // Rotation

    batch.setColor(oldColor);
}
 
開發者ID:Entwicklerpages,項目名稱:school-game,代碼行數:31,代碼來源:Rabbit.java

示例7: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
    if (!isVisible()) return;

    Color color = getColor();
    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    batch.draw(texture, getX() - 10, getY() - 10);
}
 
開發者ID:conquest,項目名稱:conquest,代碼行數:9,代碼來源:City.java

示例8: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
    //Reset spritebatch after alpha action
    Color color = batch.getColor();
    super.draw(batch, parentAlpha);
    batch.setColor(color);
}
 
開發者ID:justinmarentette11,項目名稱:Tower-Defense-Galaxy,代碼行數:8,代碼來源:PauseWindow.java

示例9: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
    Color color = getColor();
    batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);
    batch.draw(texture, getX(), getY(), getWidth() * getScaleX(), getHeight() * getScaleY());
    table.draw(batch, parentAlpha * color.a);
    batch.setColor(color.r, color.g, color.b, 1f);
}
 
開發者ID:justinmarentette11,項目名稱:Tower-Defense-Galaxy,代碼行數:9,代碼來源:MessageWindow.java

示例10: render

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void render(Batch batch) {
    Color originalColor = batch.getColor();
    batch.setColor(color);

    batch.draw(shape.getTexture(), getPosition().x, getPosition().y, getSize().width, getSize().height);

    batch.setColor(originalColor);
}
 
開發者ID:DurianHLN,項目名稱:Polymorph,代碼行數:10,代碼來源:Mob.java

示例11: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
	if (map != null) {
		Color prev = batch.getColor();
		batch.setColor(getColor());
		batch.draw(map, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(),
				getScaleY(), getRotation());
		batch.setColor(prev);
	}
}
 
開發者ID:kyperbelt,項目名稱:KyperBox,代碼行數:11,代碼來源:TransitionManager.java

示例12: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
	public void draw(Batch batch, float parentAlpha) {
		camera.update();
		Matrix4 projection = batch.getProjectionMatrix();

//		batch.end();

//		Gdx.gl.glViewport((int) frame.x, (int) frame.y, (int) frame.width, (int) frame.height);
//		batch.setProjectionMatrix(camera.combined);
//		batch.begin();

		tint.a = parentAlpha;
		batch.setColor(tint);
		batch.draw(terrain, getX(), getY(), getWidth(), getHeight());

		// draw nation layers
		if (visibilityLookup.get(Nation.FIRE))
			batch.draw(fire, getX(), getY(), getWidth(), getHeight());
		if (visibilityLookup.get(Nation.WATER))
			batch.draw(water, getX(), getY(), getWidth(), getHeight());
		if (visibilityLookup.get(Nation.EARTH))
			batch.draw(earth, getX(), getY(), getWidth(), getHeight());
		if (visibilityLookup.get(Nation.AIR))
			batch.draw(air, getX(), getY(), getWidth(), getHeight());

//		batch.end();
//		batch.setProjectionMatrix(projection);
//		batch.begin();
//		Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	}
 
開發者ID:mcgeer,項目名稱:Climatar,代碼行數:31,代碼來源:DrawableMap.java

示例13: render

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void render(Batch batch, float deltaTime)
{
    if (body == null) return;

    animationTime += deltaTime;

    Color oldColor = batch.getColor();

    batch.setColor(1f, (health + 4)/8f, (health + 4)/8f, 1f);

    Vector2 pos = body.getPosition();
    pos.scl(Physics.PPM);

    TextureRegion region = crabAnimation.getKeyFrame(animationTime);

    batch.draw(region,                                    // TextureRegion (front, back, side)
            pos.x - region.getRegionWidth() / 2,           // Offset to the X position (character center)
            pos.y,                                        // Y position is at the foots
            region.getRegionWidth() / 2,                   // Origin X (important for flipping)
            region.getRegionHeight(),                      // Origin Y
            region.getRegionWidth(),                       // Width
            region.getRegionHeight(),                      // Height
            1f,                                           // Scale X (-1 to flip)
            1f,                                           // Scale Y
            0f);                                          // Rotation

    batch.setColor(oldColor);
}
 
開發者ID:Entwicklerpages,項目名稱:school-game,代碼行數:30,代碼來源:Crab.java

示例14: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float alpha){

    batch.setColor(shadowColor);

    if(chatOpen)
        batch.draw(skin.getRegion("white"), offsetx, chatfield.getY(), chatfield.getWidth() + 15f, chatfield.getHeight()-1);

    //font.getData().down = Unit.dp.scl(-21.5f);
    //font.getData().lineHeight = 22f;
    //chatfield.getStyle().font.getData().setScale(Vars.fontscale);

    super.draw(batch, alpha);

    float spacing = chatspace;

    chatfield.setVisible(chatOpen);
    fieldlabel.setVisible(chatOpen);

    batch.setColor(shadowColor);

    float theight = offsety + spacing + getMarginBottom();
    for(int i = 0; i < messagesShown && i < messages.size && i < fadetime; i ++){

        layout.setText(font, messages.get(i).formattedMessage, Color.WHITE, textWidth, Align.bottomLeft, true);
        theight += layout.height+textspacing;
        if(i == 0) theight -= textspacing+1;

        font.getCache().clear();
        font.getCache().addText(messages.get(i).formattedMessage, fontoffsetx + offsetx, offsety + theight, textWidth, Align.bottomLeft, true);

        if(fadetime-i < 1f && fadetime-i >= 0f){
            font.getCache().setAlphas(fadetime-i);
            batch.setColor(0, 0, 0, shadowColor.a*(fadetime-i));
        }

        batch.draw(skin.getRegion("white"), offsetx, theight-layout.height-2, textWidth + Unit.dp.scl(4f), layout.height+textspacing);
        batch.setColor(shadowColor);

        font.getCache().draw(batch);
    }

    batch.setColor(Color.WHITE);

    if(fadetime > 0 && !chatOpen)
        fadetime -= Timers.delta()/180f;
}
 
開發者ID:Anuken,項目名稱:Mindustry,代碼行數:48,代碼來源:ChatFragment.java

示例15: drawSplits

import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
public void drawSplits(Batch batch, float parentAlpha) {
    batch.end();
    Gdx.gl.glLineWidth(1.0f);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
    Matrix4 matrix = batch.getTransformMatrix();
    shapeRenderer.setTransformMatrix(matrix);

    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);

    // left, right, top , bottom
    Color guideColor = new Color(GUIDE_COLOR);
    guideColor.a*=parentAlpha;
    Color overColor = new Color(OVER_GUIDE_COLOR);
    overColor.a*=parentAlpha;

    splitPositions[0] = shift.x + getWidth() / 2f + (-texture.getRegionWidth() / 2f + splits[0]) * currZoom;
    splitPositions[1] = shift.x + getWidth() / 2f + (texture.getRegionWidth() / 2f - splits[1]) * currZoom;
    splitPositions[2] = shift.y + getHeight()/2f + (texture.getRegionHeight()/2 - splits[2])*currZoom;
    splitPositions[3] = shift.y + getHeight() / 2f + (-texture.getRegionHeight() / 2 + splits[3]) * currZoom;


    if(mouseOverSplit == 0) shapeRenderer.setColor(overColor); else shapeRenderer.setColor(guideColor);
    shapeRenderer.line(getX() + splitPositions[0], getY(), getX() + splitPositions[0], getY() + getHeight());

    if(mouseOverSplit == 1) shapeRenderer.setColor(overColor); else shapeRenderer.setColor(guideColor);
    shapeRenderer.line(getX() + splitPositions[1], getY(), getX() + splitPositions[1], getY() + getHeight());

    if(mouseOverSplit == 2) shapeRenderer.setColor(overColor); else shapeRenderer.setColor(guideColor);
    shapeRenderer.line(getX(), getY() + splitPositions[2], getX() + getWidth(), getY() + splitPositions[2]);

    if(mouseOverSplit == 3) shapeRenderer.setColor(overColor); else shapeRenderer.setColor(guideColor);
    shapeRenderer.line(getX(), getY() + splitPositions[3], getX() + getWidth(), getY() + splitPositions[3]);

    shapeRenderer.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
    batch.setColor(Color.WHITE.r, Color.WHITE.g, Color.WHITE.b, Color.WHITE.a * parentAlpha);
}
 
開發者ID:whitecostume,項目名稱:libgdx_ui_editor,代碼行數:42,代碼來源:EditingZone.java


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