本文整理汇总了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();
}
示例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: 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);
}
示例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);
}