本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.Image.getWidth()
方法的一些代码示例,展示了Image.getWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Image.getWidth()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.Image
类名称:Image
方法名:getWidth
暂无
代码示例来源:origin: libgdx/libgdx
public void layout () {
if (drawable == null) return;
float regionWidth = drawable.getMinWidth();
float regionHeight = drawable.getMinHeight();
float width = getWidth();
float height = getHeight();
Vector2 size = scaling.apply(regionWidth, regionHeight, width, height);
imageWidth = size.x;
imageHeight = size.y;
if ((align & Align.left) != 0)
imageX = 0;
else if ((align & Align.right) != 0)
imageX = (int)(width - imageWidth);
else
imageX = (int)(width / 2 - imageWidth / 2);
if ((align & Align.top) != 0)
imageY = (int)(height - imageHeight);
else if ((align & Align.bottom) != 0)
imageY = 0;
else
imageY = (int)(height / 2 - imageHeight / 2);
}
代码示例来源:origin: libgdx/libgdx
public void layout () {
if (drawable == null) return;
float regionWidth = drawable.getMinWidth();
float regionHeight = drawable.getMinHeight();
float width = getWidth();
float height = getHeight();
Vector2 size = scaling.apply(regionWidth, regionHeight, width, height);
imageWidth = size.x;
imageHeight = size.y;
if ((align & Align.left) != 0)
imageX = 0;
else if ((align & Align.right) != 0)
imageX = (int)(width - imageWidth);
else
imageX = (int)(width / 2 - imageWidth / 2);
if ((align & Align.top) != 0)
imageY = (int)(height - imageHeight);
else if ((align & Align.bottom) != 0)
imageY = 0;
else
imageY = (int)(height / 2 - imageHeight / 2);
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
if(pressed){
boolean newIsLeft = toggleButton.getX() + toggleButton.getWidth()/2 < background.getWidth()/2;
if(toggleListener != null && isLeft != newIsLeft){
toggleListener.widgetToggled(newIsLeft);
}
isLeft = newIsLeft;
animating = true;
pressed = false;
toggleButton.setDrawable(style.toggleButtonDrawable);
}
super.touchUp(event, x, y, pointer, button);
}
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
@Override
public void build(Map<String, String> attr, AssetsInterface assets,
ResolutionHelper resHelper, LocalizationService locale) {
Label label = findActor("label");
Image image = findActor("thisImage");
label.setText("This is image's width is: " + image.getWidth());
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
@Override
public void build(Map<String, String> attributes, AssetsInterface assetsInterface, ResolutionHelper resolutionHelper, LocalizationService localizationService) {
float sizeMult = resolutionHelper.getSizeMultiplier();
float posMult = resolutionHelper.getPositionMultiplier();
readConfiguration(attributes, sizeMult);
prepareBackgroundImage(assetsInterface, sizeMult);
prepareNinepatch(assetsInterface, sizeMult);
prepareLabel(assetsInterface);
this.setName(attributes.get("name"));
float x = Float.valueOf(attributes.get("x")) * posMult;
float y = Float.valueOf(attributes.get("y")) * posMult;
this.setPosition(x, y);
this.progressBarLength = this.backgroundImage.getWidth() - (this.progressImagePaddingLeft + this.progressImagePaddingRight);
addActor(this.backgroundImage);
addActor(this.progressBarNinePatch);
addActor(this.progressText);
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
public void layout () {
if (drawable == null) return;
float regionWidth = drawable.getMinWidth();
float regionHeight = drawable.getMinHeight();
float width = getWidth();
float height = getHeight();
Vector2 size = scaling.apply(regionWidth, regionHeight, width, height);
imageWidth = size.x;
imageHeight = size.y;
if ((align & Align.left) != 0)
imageX = 0;
else if ((align & Align.right) != 0)
imageX = (int)(width - imageWidth);
else
imageX = (int)(width / 2 - imageWidth / 2);
if ((align & Align.top) != 0)
imageY = (int)(height - imageHeight);
else if ((align & Align.bottom) != 0)
imageY = 0;
else
imageY = (int)(height / 2 - imageHeight / 2);
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
private void prepareBackgroundImage(AssetsInterface assets, float sizeMult) {
TextureAtlas atlas = assets.getTextureAtlas(this.atlasName);
this.backgroundImage = new Image(atlas.findRegion(this.backgroundImageFrame));
this.backgroundImage.setWidth(this.backgroundImage.getWidth() * sizeMult);
this.backgroundImage.setHeight(this.backgroundImage.getHeight() * sizeMult);
}
代码示例来源:origin: com.lwgame.gdx/lwgame-core
@Override
public void create() {
texture = new Texture("badlogic.jpg");
Image image = new Image(texture);
image.setPosition((stage.getWidth() - image.getWidth()) / 2, (stage.getHeight() - image.getHeight()) / 2);
stage.addActor(image);
}
@Override
代码示例来源:origin: com.lwgame.gdx/core
@Override
public void create() {
texture = new Texture("badlogic.jpg");
Image image = new Image(texture);
image.setPosition((stage.getWidth() - image.getWidth()) / 2, (stage.getHeight() - image.getHeight()) / 2);
stage.addActor(image);
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
private void updateBackgroundImagePosition(Image image) {
Vector2 selectedResolution = assets.findBestResolution();
Vector2 backGroundSize = resolutionHelper.calculateBackgroundSize(selectedResolution.x, selectedResolution.y);
image.setWidth(backGroundSize.x);
image.setHeight(backGroundSize.y);
Vector2 backGroundPosition = resolutionHelper.calculateBackgroundPosition(image.getWidth(), image.getHeight());
Vector2 gameAreaPosition = resolutionHelper.getGameAreaPosition();
/*
* stage root position is always set to gameAreaPosition.
* Since the bg image is also inside the root group, bg image position should be updated.
*/
image.setPosition(backGroundPosition.x - gameAreaPosition.x, backGroundPosition.y - gameAreaPosition.y);
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
public ToggleWidget(ToggleWidgetStyle style) {
this.style = style;
background = new Image(style.backgroundDrawable);
addActor(background);
toggleButton = new Image(style.toggleButtonDrawable);
addActor(toggleButton);
float width = background.getWidth();
float height = Math.max(toggleButton.getHeight(), background.getHeight());
setWidth(width);
setHeight(height);
background.setY((getHeight()-background.getHeight())/2);
toggleButton.setY((getHeight()-toggleButton.getHeight())/2);
addListener(new ToggleWidgetClickListener());
maxButtonX = getWidth() - toggleButton.getWidth();
minButtonX = 0;
minButtonX += style.toggleButtonPadding/2;
maxButtonX -= style.toggleButtonPadding/2;
isLeft = true;
toggleButton.setX(minButtonX);
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
private void prepareLabel(AssetsInterface assets) {
Label.LabelStyle labelStyle = new Label.LabelStyle(assets.getFont(this.fontName), Color.WHITE);
if (this.text != null) {
this.progressText = new Label(this.text, labelStyle);
} else {
this.progressText = new Label("", labelStyle);
}
this.progressText.setWidth(this.backgroundImage.getWidth());
this.progressText.setAlignment(Align.center);
this.progressText.setPosition(this.backgroundImage.getX(), (this.backgroundImage.getHeight() - this.progressText.getHeight()) * 0.5f);
}
代码示例来源:origin: kbz/SIFTrain
splashImage.setX(stage.getWidth() / 2 - (scale * splashImage.getWidth()) / 2);
loadingProgress.setSize(scale * splashImage.getWidth() * 0.7f, stage.getHeight() * 0.07f);
loadingProgress.setX(splashImage.getX() + scale * splashImage.getWidth() * 0.15f);
loadingProgress.setY(stage.getHeight()*0.2f);
loadingProgress.setAnimateDuration(0.01f);
代码示例来源:origin: peakgames/libgdx-stagebuilder
this.boundaryHeight = resolutionHelper.getScreenHeight();
setSize(boundaryWidth, boundaryHeight);
backgroundImage.setPosition(boundaryWidth / 2 - this.backgroundImage.getWidth() / 2, boundaryHeight / 2 - this.backgroundImage.getHeight() / 2);
foregroundImage.setPosition(boundaryWidth / 2 - this.foregroundImage.getWidth() / 2, boundaryHeight / 2 - this.foregroundImage.getHeight() / 2);
if(messageLabel != null) {
messageLabel.setPosition(boundaryWidth / 2 - halfOfMessageLabelWidth, boundaryHeight / 2 - halfOfMessageLabelHeight);
foregroundImage.setSize(boundaryWidth, boundaryHeight);
if(messageLabel != null) {
messageLabel.setPosition(backgroundImage.getWidth() / 2 - halfOfMessageLabelWidth, backgroundImage.getHeight() / 2 - halfOfMessageLabelHeight);
foregroundImage.setOrigin(foregroundImage.getWidth() / 2, foregroundImage.getHeight() / 2);
backgroundImage.setOrigin(backgroundImage.getWidth() / 2, backgroundImage.getHeight() / 2);
代码示例来源:origin: kotcrab/vis-ui
public void draw (Batch batch, Image parent) {
ShaderProgram originalShader = batch.getShader();
batch.setShader(gridShader);
gridShader.setUniformf("u_width", parent.getWidth());
gridShader.setUniformf("u_height", parent.getHeight());
gridShader.setUniformf("u_gridSize", gridSize);
batch.draw(whiteTexture, parent.getX() + parent.getImageX(), parent.getY() + parent.getImageY(),
parent.getImageWidth() * parent.getScaleX(), parent.getImageHeight() * parent.getScaleY());
batch.setShader(originalShader);
}
}
代码示例来源:origin: xietansheng/Game2048ForGDX
bgImage.setOrigin(0, 0);
bgImage.setScale(getWidth() / bgImage.getWidth(), getHeight() / bgImage.getHeight());
addActor(bgImage);
helpContentImage.setX(getWidth() / 2 - helpContentImage.getWidth() / 2);
代码示例来源:origin: langurmonkey/gaiasky
switch (tabTitleAlign) {
case Align.left:
leftCell.width(((Image) leftCell.getActor()).getWidth()).bottom();
midCell.left();
rightCell.expandX().fillX().bottom();
leftCell.expandX().fillX().bottom();
midCell.right();
rightCell.width(((Image) rightCell.getActor()).getWidth()).bottom();
break;
case Align.center:
代码示例来源:origin: xietansheng/Game2048ForGDX
setSize(bgImage.getWidth(), bgImage.getHeight());
代码示例来源:origin: 121077313/cocostudio-ui-libgdx
if (tr != null) {
Image bg = new Image(tr);
bg.setPosition((size.getWidth() - bg.getWidth()) / 2,
(size.getHeight() - bg.getHeight()) / 2);
代码示例来源:origin: xietansheng/Game2048ForGDX
bgImage.setOrigin(0, 0);
bgImage.setScaleX(getWidth() / bgImage.getWidth());
addActor(bgImage);
内容来源于网络,如有侵权,请联系作者删除!