com.badlogic.gdx.scenes.scene2d.ui.Image.getHeight()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(163)

本文整理了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

Image.getHeight介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

  1. public void layout () {
  2. if (drawable == null) return;
  3. float regionWidth = drawable.getMinWidth();
  4. float regionHeight = drawable.getMinHeight();
  5. float width = getWidth();
  6. float height = getHeight();
  7. Vector2 size = scaling.apply(regionWidth, regionHeight, width, height);
  8. imageWidth = size.x;
  9. imageHeight = size.y;
  10. if ((align & Align.left) != 0)
  11. imageX = 0;
  12. else if ((align & Align.right) != 0)
  13. imageX = (int)(width - imageWidth);
  14. else
  15. imageX = (int)(width / 2 - imageWidth / 2);
  16. if ((align & Align.top) != 0)
  17. imageY = (int)(height - imageHeight);
  18. else if ((align & Align.bottom) != 0)
  19. imageY = 0;
  20. else
  21. imageY = (int)(height / 2 - imageHeight / 2);
  22. }

代码示例来源:origin: libgdx/libgdx

  1. public void layout () {
  2. if (drawable == null) return;
  3. float regionWidth = drawable.getMinWidth();
  4. float regionHeight = drawable.getMinHeight();
  5. float width = getWidth();
  6. float height = getHeight();
  7. Vector2 size = scaling.apply(regionWidth, regionHeight, width, height);
  8. imageWidth = size.x;
  9. imageHeight = size.y;
  10. if ((align & Align.left) != 0)
  11. imageX = 0;
  12. else if ((align & Align.right) != 0)
  13. imageX = (int)(width - imageWidth);
  14. else
  15. imageX = (int)(width / 2 - imageWidth / 2);
  16. if ((align & Align.top) != 0)
  17. imageY = (int)(height - imageHeight);
  18. else if ((align & Align.bottom) != 0)
  19. imageY = 0;
  20. else
  21. imageY = (int)(height / 2 - imageHeight / 2);
  22. }

代码示例来源:origin: peakgames/libgdx-stagebuilder

  1. public ToggleWidget(ToggleWidgetStyle style) {
  2. this.style = style;
  3. background = new Image(style.backgroundDrawable);
  4. addActor(background);
  5. toggleButton = new Image(style.toggleButtonDrawable);
  6. addActor(toggleButton);
  7. float width = background.getWidth();
  8. float height = Math.max(toggleButton.getHeight(), background.getHeight());
  9. setWidth(width);
  10. setHeight(height);
  11. background.setY((getHeight()-background.getHeight())/2);
  12. toggleButton.setY((getHeight()-toggleButton.getHeight())/2);
  13. addListener(new ToggleWidgetClickListener());
  14. maxButtonX = getWidth() - toggleButton.getWidth();
  15. minButtonX = 0;
  16. minButtonX += style.toggleButtonPadding/2;
  17. maxButtonX -= style.toggleButtonPadding/2;
  18. isLeft = true;
  19. toggleButton.setX(minButtonX);
  20. }

代码示例来源:origin: com.badlogicgames.gdx/gdx

  1. public void layout () {
  2. if (drawable == null) return;
  3. float regionWidth = drawable.getMinWidth();
  4. float regionHeight = drawable.getMinHeight();
  5. float width = getWidth();
  6. float height = getHeight();
  7. Vector2 size = scaling.apply(regionWidth, regionHeight, width, height);
  8. imageWidth = size.x;
  9. imageHeight = size.y;
  10. if ((align & Align.left) != 0)
  11. imageX = 0;
  12. else if ((align & Align.right) != 0)
  13. imageX = (int)(width - imageWidth);
  14. else
  15. imageX = (int)(width / 2 - imageWidth / 2);
  16. if ((align & Align.top) != 0)
  17. imageY = (int)(height - imageHeight);
  18. else if ((align & Align.bottom) != 0)
  19. imageY = 0;
  20. else
  21. imageY = (int)(height / 2 - imageHeight / 2);
  22. }

代码示例来源:origin: peakgames/libgdx-stagebuilder

  1. private void prepareBackgroundImage(AssetsInterface assets, float sizeMult) {
  2. TextureAtlas atlas = assets.getTextureAtlas(this.atlasName);
  3. this.backgroundImage = new Image(atlas.findRegion(this.backgroundImageFrame));
  4. this.backgroundImage.setWidth(this.backgroundImage.getWidth() * sizeMult);
  5. this.backgroundImage.setHeight(this.backgroundImage.getHeight() * sizeMult);
  6. }

代码示例来源:origin: com.lwgame.gdx/lwgame-core

  1. @Override
  2. public void create() {
  3. texture = new Texture("badlogic.jpg");
  4. Image image = new Image(texture);
  5. image.setPosition((stage.getWidth() - image.getWidth()) / 2, (stage.getHeight() - image.getHeight()) / 2);
  6. stage.addActor(image);
  7. }
  8. @Override

代码示例来源:origin: com.lwgame.gdx/core

  1. @Override
  2. public void create() {
  3. texture = new Texture("badlogic.jpg");
  4. Image image = new Image(texture);
  5. image.setPosition((stage.getWidth() - image.getWidth()) / 2, (stage.getHeight() - image.getHeight()) / 2);
  6. stage.addActor(image);
  7. }

代码示例来源:origin: peakgames/libgdx-stagebuilder

  1. private void updateBackgroundImagePosition(Image image) {
  2. Vector2 selectedResolution = assets.findBestResolution();
  3. Vector2 backGroundSize = resolutionHelper.calculateBackgroundSize(selectedResolution.x, selectedResolution.y);
  4. image.setWidth(backGroundSize.x);
  5. image.setHeight(backGroundSize.y);
  6. Vector2 backGroundPosition = resolutionHelper.calculateBackgroundPosition(image.getWidth(), image.getHeight());
  7. Vector2 gameAreaPosition = resolutionHelper.getGameAreaPosition();
  8. /*
  9. * stage root position is always set to gameAreaPosition.
  10. * Since the bg image is also inside the root group, bg image position should be updated.
  11. */
  12. image.setPosition(backGroundPosition.x - gameAreaPosition.x, backGroundPosition.y - gameAreaPosition.y);
  13. }

代码示例来源:origin: peakgames/libgdx-stagebuilder

  1. private void prepareLabel(AssetsInterface assets) {
  2. Label.LabelStyle labelStyle = new Label.LabelStyle(assets.getFont(this.fontName), Color.WHITE);
  3. if (this.text != null) {
  4. this.progressText = new Label(this.text, labelStyle);
  5. } else {
  6. this.progressText = new Label("", labelStyle);
  7. }
  8. this.progressText.setWidth(this.backgroundImage.getWidth());
  9. this.progressText.setAlignment(Align.center);
  10. this.progressText.setPosition(this.backgroundImage.getX(), (this.backgroundImage.getHeight() - this.progressText.getHeight()) * 0.5f);
  11. }

代码示例来源:origin: peakgames/libgdx-stagebuilder

  1. this.boundaryHeight = resolutionHelper.getScreenHeight();
  2. setSize(boundaryWidth, boundaryHeight);
  3. backgroundImage.setPosition(boundaryWidth / 2 - this.backgroundImage.getWidth() / 2, boundaryHeight / 2 - this.backgroundImage.getHeight() / 2);
  4. foregroundImage.setPosition(boundaryWidth / 2 - this.foregroundImage.getWidth() / 2, boundaryHeight / 2 - this.foregroundImage.getHeight() / 2);
  5. if(messageLabel != null) {
  6. messageLabel.setPosition(boundaryWidth / 2 - halfOfMessageLabelWidth, boundaryHeight / 2 - halfOfMessageLabelHeight);
  7. foregroundImage.setSize(boundaryWidth, boundaryHeight);
  8. if(messageLabel != null) {
  9. messageLabel.setPosition(backgroundImage.getWidth() / 2 - halfOfMessageLabelWidth, backgroundImage.getHeight() / 2 - halfOfMessageLabelHeight);
  10. foregroundImage.setOrigin(foregroundImage.getWidth() / 2, foregroundImage.getHeight() / 2);
  11. backgroundImage.setOrigin(backgroundImage.getWidth() / 2, backgroundImage.getHeight() / 2);

代码示例来源:origin: kotcrab/vis-ui

  1. public void draw (Batch batch, Image parent) {
  2. ShaderProgram originalShader = batch.getShader();
  3. batch.setShader(gridShader);
  4. gridShader.setUniformf("u_width", parent.getWidth());
  5. gridShader.setUniformf("u_height", parent.getHeight());
  6. gridShader.setUniformf("u_gridSize", gridSize);
  7. batch.draw(whiteTexture, parent.getX() + parent.getImageX(), parent.getY() + parent.getImageY(),
  8. parent.getImageWidth() * parent.getScaleX(), parent.getImageHeight() * parent.getScaleY());
  9. batch.setShader(originalShader);
  10. }
  11. }

代码示例来源:origin: xietansheng/Game2048ForGDX

  1. bgImage.setOrigin(0, 0);
  2. bgImage.setScale(getWidth() / bgImage.getWidth(), getHeight() / bgImage.getHeight());
  3. addActor(bgImage);
  4. helpContentImage.setY(getHeight() - helpContentImage.getHeight());
  5. addActor(helpContentImage);

代码示例来源:origin: peakgames/libgdx-stagebuilder

  1. float height = backgroundImage.getHeight();
  2. setHeight(height);
  3. backgroundImage.setSize(maxWidth, height);

代码示例来源:origin: xietansheng/Game2048ForGDX

  1. setSize(bgImage.getWidth(), bgImage.getHeight());

代码示例来源:origin: xietansheng/Game2048ForGDX

  1. private void init() {
  2. /*
  3. * 2048 LOGO
  4. */
  5. logoImage = new Image(getMainGame().getAtlas().findRegion(Res.AtlasNames.GAME_LOGO));
  6. logoImage.setX(20);
  7. addActor(logoImage);
  8. // 设置组的宽高(以世界的宽度, LOGO 的高度 作为组的宽高)
  9. setSize(getMainGame().getWorldWidth(), logoImage.getHeight());
  10. /*
  11. * 当前分数
  12. */
  13. currScoreGroup = new ScoreGroup(getMainGame(), getMainGame().getAtlas().findRegion(Res.AtlasNames.GAME_SCORE_BG_NOW));
  14. currScoreGroup.setX(186);
  15. currScoreGroup.setY(getHeight() - currScoreGroup.getHeight()); // 设置到组的顶部
  16. addActor(currScoreGroup);
  17. /*
  18. * 最佳分数
  19. */
  20. bestScoreGroup = new ScoreGroup(getMainGame(), getMainGame().getAtlas().findRegion(Res.AtlasNames.GAME_SCORE_BG_BEST));
  21. bestScoreGroup.setX(334);
  22. bestScoreGroup.setY(getHeight() - bestScoreGroup.getHeight());
  23. addActor(bestScoreGroup);
  24. }

代码示例来源:origin: xietansheng/Game2048ForGDX

  1. bgImage.setOrigin(0, 0);
  2. bgImage.setScale(getWidth() / bgImage.getWidth(), getHeight() / bgImage.getHeight());
  3. addActor(bgImage);

代码示例来源:origin: 121077313/cocostudio-ui-libgdx

  1. Image bg = new Image(tr);
  2. bg.setPosition((size.getWidth() - bg.getWidth()) / 2,
  3. (size.getHeight() - bg.getHeight()) / 2);

代码示例来源:origin: xietansheng/Game2048ForGDX

  1. setSize(bgImage.getWidth(), bgImage.getHeight());

代码示例来源:origin: xietansheng/Game2048ForGDX

  1. bgImage.setOrigin(0, 0);
  2. bgImage.setScale(getWidth() / bgImage.getWidth(), getHeight() / bgImage.getHeight());
  3. addActor(bgImage);

代码示例来源:origin: xietansheng/Game2048ForGDX

  1. bgImage.setScaleY(getHeight() / bgImage.getHeight());

相关文章