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


Java Sprite.getWidth方法代碼示例

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


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

示例1: 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

示例2: SpaceObject

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public SpaceObject(Sprite sprite, int color) {
    this.sprite = sprite;
    this.color = color;

    drawColor = new Color(color);

    if(sprite != null) {
        this.size = (int)sprite.getWidth();
    }
}
 
開發者ID:ZKasica,項目名稱:Planet-Generator,代碼行數:11,代碼來源:SpaceObject.java

示例3: setupSplashImage

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void setupSplashImage() {
    DS.game.manager.load(splashImgFilename, Texture.class);
    manager.finishLoading();
    splashLogo = new Sprite(DS.game.manager.get(splashImgFilename, Texture.class));
    splashLogo.getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    double SCALE = DS.T_WIDTH/splashLogo.getWidth();

    if(DS.app_orientation == DS.ORIENTATION.PORTRAIT) {
        splashLogo.setSize((float) (splashLogo.getWidth() * SCALE), (float) (splashLogo.getHeight() * SCALE));
    } else {
        SCALE = DS.T_HEIGHT/splashLogo.getHeight();
        splashLogo.setSize((float) (splashLogo.getWidth() * SCALE), (float) (splashLogo.getHeight() * SCALE));
    }
    int imgX = (int)(DS.T_WIDTH/2.0 - splashLogo.getWidth()/2.0);
    int imgY = (int)(DS.T_HEIGHT/2.0 - splashLogo.getHeight()/2.0);
    Gdx.app.debug(ID, "splshlogo Width: " + splashLogo.getWidth());
    Gdx.app.debug(ID, "splshlogo Height: " + splashLogo.getHeight());
    Gdx.app.debug(ID, "imgX: " + imgX);
    Gdx.app.debug(ID, "imgY: " + imgY);
    splashLogo.setPosition(imgX, imgY);
}
 
開發者ID:dsaves,項目名稱:Ponytron,代碼行數:22,代碼來源:SPLASH.java

示例4: Planet

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public Planet(Sprite sprite, Pixmap pixmap, int direction) {
    super(sprite);
    this.pixmap = pixmap;
    this.direction = direction;

    rotationSpeed = 1/50f;
    radius = sprite.getWidth()/2;

    planetShader = new ShaderProgram(Gdx.files.internal("shaders/planet.vsh"), Gdx.files.internal("shaders/planet.fsh"));
    if(!planetShader.isCompiled()) {
        Gdx.app.error("Planet Shader Error", "\n" + planetShader.getLog());
    }
}
 
開發者ID:ZKasica,項目名稱:Planet-Generator,代碼行數:14,代碼來源:Planet.java


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