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


Java Sprite.draw方法代碼示例

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


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

示例1: processEntity

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
@Override
protected void processEntity(Entity entity, float deltaTime) {

	if (_tile != null) {
		_batch.begin();
		TextureRegion textureRegion = _tile.getCell().getTile().getTextureRegion();
		Sprite sprite = new Sprite(textureRegion);

		if (!isLegalPlacement()) {
			sprite.setColor(Color.RED);
			sprite.setAlpha(0.5f);
		} else {
			sprite.setColor(Color.GREEN);
			sprite.setAlpha(0.5f);
		}
		sprite.setPosition(_tile.getCords().x, _tile.getCords().y);
		sprite.draw(_batch);
		_batch.end();
	}
}
 
開發者ID:JoakimRW,項目名稱:ExamensArbeteTD,代碼行數:21,代碼來源:TowerPlacementSystem.java

示例2: draw

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
	if (sprite != null && !sprite.isEmpty() && !sprite.equals(NO_SPRITE)) {
		Sprite render = layer.getGameSprite(sprite);
		render.setPosition(MathUtils.round(getX()), MathUtils.round(getY()));
		render.setRotation(getRotation());
		render.setAlpha(getColor().a * parentAlpha);
		render.setOrigin(getOriginX(), getOriginY());
		render.setColor(getColor());
		render.setSize(getWidth(), getHeight());
		render.setScale(getScaleX(), getScaleY());
		render.setFlip(flip_x, flip_y);
		render.draw(batch);
	}
	super.draw(batch, parentAlpha);
}
 
開發者ID:kyperbelt,項目名稱:KyperBox,代碼行數:17,代碼來源:GameObject.java

示例3: drawSprite

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void drawSprite(SpriteBatch batch, Sprite sprite, int scene, Interactable interactable) {
	if (interactable.isConsumed()) {
		sprite.draw(batch);
		return;
	}
	Rectangle handle = null;
	if (dragsLeftHandle)
		handle = rectangleLeftHandle;
	if (dragsRightHandle)
		handle = rectangleRightHandle;
	if (handle == null)
		return;
	float percentage = (Math.min(sprite.getWidth(), Math.max(0, handle.x - sprite.getX())) / sprite.getWidth());
	boolean reverseDirection = (scene == 1 && dragsLeftHandle || scene == 2 && dragsRightHandle);
	if (reverseDirection) {
		percentage = 1 - percentage;
	}
	int visibleWidth = (int) (sprite.getWidth() * percentage);
	batch.draw(sprite.getTexture(), (reverseDirection ? sprite.getWidth() - visibleWidth : 0) + sprite.getX(), sprite.getY(), sprite.getWidth() / 2, sprite.getHeight() / 2, visibleWidth, sprite.getHeight(), sprite.getScaleX() * (interactable.isConsumable() ? scaleFactor : 1),
			sprite.getScaleY() * (interactable.isConsumable() ? scaleFactor : 1), 0, sprite.getRegionX(), sprite.getRegionY(), (int) (sprite.getRegionWidth() * percentage), sprite.getRegionHeight(), reverseDirection, false);
}
 
開發者ID:cdetamble,項目名稱:nomoore,代碼行數:22,代碼來源:ScreenGame.java

示例4: drawHealthBar

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void drawHealthBar(HealthComponent healthComp, PositionComponent pos) {
	final float healthBarHeight = Assets.enemyRedHealthbarBG.getHeight();
	final float healthBarWidth = Assets.enemyRedHealthbarBG.getWidth();
	// getting the scale ratio
	final double ratio = healthBarWidth / healthComp.maxHealth;
	Sprite spriteBg = Assets.enemyRedHealthbarBG;
	Sprite sprite = Assets.enemyGreenHealthbarBG;
	// todo center hp bar
	sprite.setPosition(pos.position.x, pos.position.y);
	spriteBg.setPosition(pos.position.x, pos.position.y);
	if(healthComp.health > 0)
		sprite.setSize((float) (ratio * healthComp.health), healthBarHeight);
	// 100 %
	if (healthComp.health <= healthComp.maxHealth)
		sprite.setColor(0, 0.75f, 0, 1f);
	// 75 %
	if (healthComp.health <= 0.75 * healthComp.maxHealth)
		sprite.setColor(Color.YELLOW);
	// 50%
	if (healthComp.health <= 0.50 * healthComp.maxHealth)
		sprite.setColor(Color.ORANGE);
	// 25%
	if (healthComp.health <= 0.25 * healthComp.maxHealth)
		sprite.setColor(Color.BROWN);
	// if enemy isn't hurt don't draw health.
	if (healthComp.health != healthComp.maxHealth) {
		_batch.begin();
		spriteBg.draw(_batch);
		sprite.draw(_batch);
		_batch.end();
	}
}
 
開發者ID:JoakimRW,項目名稱:ExamensArbeteTD,代碼行數:33,代碼來源:HealthSystem.java

示例5: drawNametable

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void drawNametable(GGVm ggvm, SpriteBatch spriteBatch, int scrollX, int scrollY, float splitYStart, float splitYEnd) {
    int patternTable = ggvm.getBackgroundPatternTableAddress() == 0 ? 0 : 1;

    boolean toggleNametableEarly = false;
    if (scrollY > 239 && scrollY <= 255) {
        scrollY -= 16;
        toggleNametableEarly = true;
    }

    int coarseScrollX = scrollX >> 3;
    int coarseScrollY = scrollY >> 3;
    int fineScrollX = scrollX & 7;
    int fineScrollY = scrollY & 7;

    int nameTableX = coarseScrollX;
    int nameTableY = coarseScrollY;
    int actualNameTableX;
    int actualNameTableY;
    int screenX = 0;
    int screenY = 8;
    int nameTableRowCount = fineScrollY == 0 ? 30 : 31;
    int nameTableColumnCount = 33;
    int nameTable;

    while (nameTableColumnCount > 0) {
        screenY = 0;
        nameTableRowCount = fineScrollY == 0 ? 30 : 31;
        nameTableY = coarseScrollY;
        nameTable = (ggvm.getNametableAddress() == Ppu.NAME_TABLE_0_BASE_ADDRESS) ? 0 : 1;
        if (toggleNametableEarly) {
            nameTable ^= 1;
        }
        while (nameTableRowCount > 0) {
            actualNameTableX = nameTableX % 32;
            actualNameTableY = nameTableY % 30;
            int whichNameTable = nameTable ^ (nameTableY / 30);

            int nameTableAddress = whichNameTable == 1 ? Ppu.NAME_TABLE_2_BASE_ADDRESS : Ppu.NAME_TABLE_0_BASE_ADDRESS;
            int attributeTableAddress = whichNameTable == 1 ? Ppu.ATTRIBUTE_TABLE_2_BASE_ADDRESS : Ppu.ATTRIBUTE_TABLE_0_BASE_ADDRESS;

            int index = ggvm.getNametableTile(nameTableAddress, actualNameTableX, actualNameTableY);
            int attribute = ggvm.getAttributeForNametableTile(attributeTableAddress, actualNameTableX, actualNameTableY);

            int indexRow = index >> 4;
            int indexColumn = index & 0x0f;
            Sprite sprite = patternTableManager.getSprite(patternTable, indexRow, indexColumn);//patternTableSprites[patternTableOffset * 16 + indexRow][indexColumn];
            sprite.setColor(0, attributes[attribute], 0, 0);
            if (!GGVmRegisterStatusBar.isSprite0HitStatusBarEnabled() || (screenY >= splitYStart && screenY < splitYEnd)) {
                sprite.setPosition(screenX - fineScrollX, 232 - screenY + fineScrollY);
                sprite.draw(spriteBatch);
            }
            screenY += 8;
            nameTableY++;
            nameTableRowCount--;
        }
        screenX += 8;
        nameTableX++;
        nameTableColumnCount--;
    }
}
 
開發者ID:gradualgames,項目名稱:ggvm,代碼行數:61,代碼來源:HorizontalMirroringRenderManager.java

示例6: drawNametable

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void drawNametable(GGVm ggvm, SpriteBatch spriteBatch, int scrollX, int scrollY, float splitYStart, float splitYEnd) {
    int patternTable = ggvm.getBackgroundPatternTableAddress() == 0 ? 0 : 1;

    boolean toggleNametableEarly = false;
    if (scrollY > 239 && scrollY <= 255) {
        scrollY -= 16;
        toggleNametableEarly = true;
    }

    int coarseScrollX = scrollX >> 3;
    int coarseScrollY = scrollY >> 3;
    int fineScrollX = scrollX & 7;
    int fineScrollY = scrollY & 7;

    int nameTableX = coarseScrollX;
    int nameTableY = coarseScrollY;
    int actualNameTableX;
    int actualNameTableY;
    int screenX = 0;
    int screenY = 8;
    int nameTableRowCount = fineScrollY == 0 ? 30 : 31;
    int nameTableColumnCount = 33;
    int nameTable;

    while (nameTableColumnCount > 0) {
        screenY = 0;
        nameTableRowCount = fineScrollY == 0 ? 30 : 31;
        nameTableY = coarseScrollY;
        nameTable = (ggvm.getNametableAddress() == Ppu.NAME_TABLE_0_BASE_ADDRESS) ? 0 : 1;
        if (toggleNametableEarly) {
            nameTable ^= 1;
        }
        while (nameTableRowCount > 0) {
            actualNameTableX = nameTableX % 32;
            actualNameTableY = nameTableY % 30;

            int nameTableAddress = nameTable == 1 ? Ppu.NAME_TABLE_1_BASE_ADDRESS : Ppu.NAME_TABLE_0_BASE_ADDRESS;
            int attributeTableAddress = nameTableAddress == 1 ? Ppu.ATTRIBUTE_TABLE_1_BASE_ADDRESS : Ppu.ATTRIBUTE_TABLE_0_BASE_ADDRESS;

            int index = ggvm.getNametableTile(nameTableAddress, actualNameTableX, actualNameTableY);
            int attribute = ggvm.getAttributeForNametableTile(attributeTableAddress, actualNameTableX, actualNameTableY);

            int indexRow = index >> 4;
            int indexColumn = index & 0x0f;
            Sprite sprite = patternTableManager.getSprite(patternTable, indexRow, indexColumn);//patternTableSprites[patternTableOffset * 16 + indexRow][indexColumn];
            sprite.setColor(0, attributes[attribute], 0, 0);
            //if (!GGVmRegisterStatusBar.isSprite0HitStatusBarEnabled() || (screenY >= splitYStart && screenY < splitYEnd)) {
                sprite.setPosition(screenX - fineScrollX, 232 - screenY + fineScrollY);
                sprite.draw(spriteBatch);
            //}
            screenY += 8;
            nameTableY++;
            nameTableRowCount--;
        }
        screenX += 8;
        nameTableX++;
        nameTableColumnCount--;
    }
}
 
開發者ID:gradualgames,項目名稱:ggvm,代碼行數:60,代碼來源:SingleScreenMirroringRenderManager.java

示例7: drawNametable

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void drawNametable(GGVm ggvm, SpriteBatch spriteBatch, int startingNametableAddress, int scrollX, int scrollY, float splitYStart, float splitYEnd) {
    int patternTable = ggvm.getBackgroundPatternTableAddress() == 0 ? 0 : 1;

    int coarseScrollX = scrollX >> 3;
    int coarseScrollY = scrollY >> 3;
    int fineScrollX = scrollX & 7;
    int fineScrollY = scrollY & 7;

    int nameTableX = coarseScrollX;
    int nameTableY = coarseScrollY;
    int actualNameTableX;
    int actualNameTableY;
    int screenX = 0;
    int screenY = 0;
    int nameTableRowCount = fineScrollY == 0 ? 30 : 31;
    int nameTableColumnCount;
    int nameTable;

    while (nameTableRowCount > 0) {
        screenX = 0;
        nameTableColumnCount = fineScrollX == 0 ? 32 : 33;
        nameTableX = coarseScrollX;
        nameTable = (startingNametableAddress == Ppu.NAME_TABLE_0_BASE_ADDRESS || startingNametableAddress == Ppu.NAME_TABLE_2_BASE_ADDRESS) ? 0 : 1;
        while (nameTableColumnCount > 0) {
            actualNameTableX = nameTableX % 32;
            actualNameTableY = nameTableY % 30;
            int whichNameTable = nameTable ^ ((nameTableX >> 5) & 1);

            int nameTableAddress = whichNameTable == 1 ? Ppu.NAME_TABLE_1_BASE_ADDRESS : Ppu.NAME_TABLE_0_BASE_ADDRESS;
            int attributeTableAddress = whichNameTable == 1 ? Ppu.ATTRIBUTE_TABLE_1_BASE_ADDRESS : Ppu.ATTRIBUTE_TABLE_0_BASE_ADDRESS;

            int index = ggvm.getNametableTile(nameTableAddress, actualNameTableX, actualNameTableY);
            int attribute = ggvm.getAttributeForNametableTile(attributeTableAddress, actualNameTableX, actualNameTableY);

            int indexRow = index >> 4;
            int indexColumn = index & 0x0f;
            Sprite sprite = patternTableManager.getSprite(patternTable, indexRow, indexColumn);//patternTableSprites[patternTableOffset * 16 + indexRow][indexColumn];
            sprite.setColor(0, attributes[attribute], 0, 0);
            if (!GGVmRegisterStatusBar.isSprite0HitStatusBarEnabled() || (screenY >= splitYStart && screenY < splitYEnd)) {
                sprite.setPosition(screenX - fineScrollX, 232 - screenY + fineScrollY);
                sprite.draw(spriteBatch);
            }
            screenX += 8;
            nameTableX++;
            nameTableColumnCount--;
        }
        screenY += 8;
        nameTableY++;
        nameTableRowCount--;
    }
}
 
開發者ID:gradualgames,項目名稱:ggvm,代碼行數:52,代碼來源:VerticalMirroringRenderManager.java

示例8: draw

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
	// TODO Auto-generated method stub
	super.draw(batch, parentAlpha);
	if(is_me_get_focus == false){
		if(Math.pow(this.page_no-book.current_page,2)<=book.pages_range_to_load){
			page_textrue=new Texture(Gdx.files.internal("pagestray/p"+page_no+".png"));
			page_textrue.setFilter(TextureFilter.Linear,TextureFilter.Linear);
			page_sprite = new Sprite(page_textrue); 
			page_sprite.setSize(Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
			
			is_me_get_focus = true;
			//book.android.make_toast("page no : "+page_no+" loaded", false);
		}
	}else
	{
		
		b_a_s.setColor(255/255f,27/255f,177/255f,book.bookmark_a_page == page_no? (book.stage_detector==Stages.menu?.6f:(book.them_detector ==Thems.colord?.5f:.4f)):0);
		b_b_s.setColor(27/255f,255/255f,215/255f,book.bookmark_b_page == page_no? (book.stage_detector==Stages.menu?.6f:(book.them_detector ==Thems.colord?.5f:.4f)):0);
		b_c_s.setColor(255/255f,220/255f,27/255f,book.bookmark_c_page == page_no? (book.stage_detector==Stages.menu?.6f:(book.them_detector ==Thems.colord?.5f:.4f)):0);
		
		
		b_a_s.setPosition(b_first_x,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight()+ b_y);
		b_b_s.setPosition(b_first_x+b_pading_x+b_width, book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight()+b_y);
		b_c_s.setPosition(b_first_x+2*b_pading_x+2*b_width, book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight()+b_y);
	
		back_ground.setPosition(0,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight());
		britness.setPosition(0,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight());
		
		page_sprite.setPosition(0,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight());
		page_sprite.setAlpha(book.stage_detector==Stages.menu?.3f:1);
		back_ground.setAlpha(book.them_detector ==Thems.colord?1:0);
	
		britness.setAlpha(1f-(book.light_value*.01f));
		back_ground.draw(batch);
		page_sprite.draw(batch);
		britness.draw(batch);
		b_a_s.draw(batch);
		b_b_s.draw(batch);
		b_c_s.draw(batch);
	}
	if(Math.pow(this.page_no-book.current_page,2)>book.pages_range_to_load&&is_me_get_focus){
	//	book.android.make_toast("page no : "+page_no+" unloaded", false);
		is_me_get_focus = false ;
		page_sprite = null ;
		page_textrue.dispose() ;
		
		
	}
	
}
 
開發者ID:omar6597,項目名稱:alquran-alkarem,代碼行數:52,代碼來源:PageSeen.java


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