本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.Image.getHeight()
方法的一些代码示例,展示了Image.getHeight()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Image.getHeight()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.Image
类名称:Image
方法名:getHeight
暂无
代码示例来源: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 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: 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
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: 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.setY(getHeight() - helpContentImage.getHeight());
addActor(helpContentImage);
代码示例来源:origin: peakgames/libgdx-stagebuilder
float height = backgroundImage.getHeight();
setHeight(height);
backgroundImage.setSize(maxWidth, height);
代码示例来源:origin: xietansheng/Game2048ForGDX
setSize(bgImage.getWidth(), bgImage.getHeight());
代码示例来源:origin: xietansheng/Game2048ForGDX
private void init() {
/*
* 2048 LOGO
*/
logoImage = new Image(getMainGame().getAtlas().findRegion(Res.AtlasNames.GAME_LOGO));
logoImage.setX(20);
addActor(logoImage);
// 设置组的宽高(以世界的宽度, LOGO 的高度 作为组的宽高)
setSize(getMainGame().getWorldWidth(), logoImage.getHeight());
/*
* 当前分数
*/
currScoreGroup = new ScoreGroup(getMainGame(), getMainGame().getAtlas().findRegion(Res.AtlasNames.GAME_SCORE_BG_NOW));
currScoreGroup.setX(186);
currScoreGroup.setY(getHeight() - currScoreGroup.getHeight()); // 设置到组的顶部
addActor(currScoreGroup);
/*
* 最佳分数
*/
bestScoreGroup = new ScoreGroup(getMainGame(), getMainGame().getAtlas().findRegion(Res.AtlasNames.GAME_SCORE_BG_BEST));
bestScoreGroup.setX(334);
bestScoreGroup.setY(getHeight() - bestScoreGroup.getHeight());
addActor(bestScoreGroup);
}
代码示例来源:origin: xietansheng/Game2048ForGDX
bgImage.setOrigin(0, 0);
bgImage.setScale(getWidth() / bgImage.getWidth(), getHeight() / bgImage.getHeight());
addActor(bgImage);
代码示例来源:origin: 121077313/cocostudio-ui-libgdx
Image bg = new Image(tr);
bg.setPosition((size.getWidth() - bg.getWidth()) / 2,
(size.getHeight() - bg.getHeight()) / 2);
代码示例来源:origin: xietansheng/Game2048ForGDX
setSize(bgImage.getWidth(), bgImage.getHeight());
代码示例来源:origin: xietansheng/Game2048ForGDX
bgImage.setOrigin(0, 0);
bgImage.setScale(getWidth() / bgImage.getWidth(), getHeight() / bgImage.getHeight());
addActor(bgImage);
代码示例来源:origin: xietansheng/Game2048ForGDX
bgImage.setScaleY(getHeight() / bgImage.getHeight());
内容来源于网络,如有侵权,请联系作者删除!