本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.utils.Drawable.getTopHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.getTopHeight方法的具體用法?Java Drawable.getTopHeight怎麽用?Java Drawable.getTopHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.scenes.scene2d.utils.Drawable
的用法示例。
在下文中一共展示了Drawable.getTopHeight方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
}
示例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;
}
示例3: 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);
}