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


Java Drawable.getLeftWidth方法代碼示例

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


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

示例1: EmptyDrawable

import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
/** Creates a new empty drawable with the same sizing information as the specified drawable. */
public EmptyDrawable(Drawable drawable) {
	leftWidth = drawable.getLeftWidth();
	rightWidth = drawable.getRightWidth();
	topHeight = drawable.getTopHeight();
	bottomHeight = drawable.getBottomHeight();
	minWidth = drawable.getMinWidth();
	minHeight = drawable.getMinHeight();
}
 
開發者ID:Longri,項目名稱:cachebox3.0,代碼行數:10,代碼來源:EmptyDrawable.java

示例2: calculatePositionAndValue

import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
boolean calculatePositionAndValue(float x, float y) {
    final Drawable bg = style.background;

    float value;
    float oldPosition = progressPos;

    if (vertical) {
        float height = getHeight() - bg.getTopHeight() - bg.getBottomHeight();
        progressPos = y - bg.getBottomHeight();
        value = min + (max - min) * (progressPos / height);
        progressPos = Math.max(0, progressPos);
        progressPos = Math.min(height, progressPos);
    } else {
        float width = getWidth() - bg.getLeftWidth() - bg.getRightWidth();
        progressPos = x - bg.getLeftWidth();
        value = min + (max - min) * (progressPos / width);
        progressPos = Math.max(0, progressPos);
        progressPos = Math.min(width, progressPos);
    }

    float oldValue = value;
    boolean valueSet = setValue(value);
    if (value == oldValue) {
        progressPos = oldPosition;
    }
    return valueSet;
}
 
開發者ID:varFamily,項目名稱:cocos-ui-libgdx,代碼行數:28,代碼來源:ProgressBar.java

示例3: isTextFitTextField

import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
/** Checks if the text could fit the current textField's width. */
public static boolean isTextFitTextField(VisTextField textField, String text) {
    float availableWidth = textField.getWidth();
    Drawable fieldBg = textField.getStyle().background;
    if (fieldBg != null) {
        availableWidth = availableWidth - fieldBg.getLeftWidth() - fieldBg.getRightWidth();
    }
    BitmapFont font = textField.getStyle().font;
    return isTextFitWidth(font, availableWidth, text);
}
 
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:11,代碼來源:Scene2dUtils.java

示例4: draw

import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
    ProgressBarStyle style = this.style;
    final Drawable bg = style.background;
    final Drawable knobBefore = style.progress;

    Color color = getColor();
    float x = getX();
    float y = getY();
    float width = getWidth();
    float height = getHeight();
    float value = getVisualValue();

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

    if (vertical) {
        bg.draw(batch, x + (int) ((width - bg.getMinWidth()) * 0.5f), y, bg.getMinWidth(), height);

        float progressPosHeight = height - (bg.getTopHeight() + bg.getBottomHeight());
        if (min != max) {
            progressPos = (value - min) / (max - min) * progressPosHeight;
            progressPos = Math.max(0, progressPos);
            progressPos = Math.min(progressPosHeight, progressPos) + bg.getBottomHeight();
        }

        if (knobBefore != null) {
            knobBefore.draw(batch, x + (int) ((width - knobBefore.getMinWidth()) * 0.5f), y, knobBefore.getMinWidth(),
                (int) progressPos);
        }
    } else {
        bg.draw(batch, x, y + (int) ((height - bg.getMinHeight()) * 0.5f), width, bg.getMinHeight());

        float progressPosWidth = width - (bg.getLeftWidth() + bg.getRightWidth());
        if (min != max) {
            progressPos = (value - min) / (max - min) * progressPosWidth;
            progressPos = Math.max(0, progressPos);
            progressPos = Math.min(progressPosWidth, progressPos) + bg.getLeftWidth();
        }

        if (knobBefore != null) {
            knobBefore.draw(batch, x, y + (int) ((height - knobBefore.getMinHeight()) * 0.5f), (int) progressPos,
                knobBefore.getMinHeight());
        }
    }
    super.draw(batch, parentAlpha);
}
 
開發者ID:varFamily,項目名稱:cocos-ui-libgdx,代碼行數:47,代碼來源:ProgressBar.java


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