当前位置: 首页>>代码示例>>Java>>正文


Java Scaling.fit方法代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.Scaling.fit方法的典型用法代码示例。如果您正苦于以下问题:Java Scaling.fit方法的具体用法?Java Scaling.fit怎么用?Java Scaling.fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.utils.Scaling的用法示例。


在下文中一共展示了Scaling.fit方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createLabelAndImg

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
/**
 * Erzeugt die Elemente für den Namen und das Bild des Loots.
 * 
 * @param name
 *            Name des Loots
 * @param img
 *            Bild des Loots
 */
private void createLabelAndImg(final String name, final Drawable img) {
	Table table = new Table();
	table.setFillParent(true);
	table.left().top();
	table.setBackground(new TextureRegionDrawable(AssetManager
			.getTextureRegion("ui", "buttonBackground")));

	Image icon = new Image(img, Scaling.fit);
	table.add(icon).height(70).maxWidth(120).pad(15, 0, 15, 0);

	Label desc = new Label(name, new LabelStyle(
			AssetManager.getTextFont(FontSize.FORTY), Color.DARK_GRAY));
	desc.setEllipse(true);
	table.add(desc).expandX().left();

	addActor(table);
}
 
开发者ID:PhilippGrulich,项目名称:HAW-SE2-projecthorse,代码行数:26,代码来源:AchievmentPopup.java

示例2: LetterboxingViewport

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
/** @param targetPpiX this is the targeted pixel per inch ratio on X axis, which allows to scale the viewport
 *            correctly on different devices. Usually about 96 for desktop and WebGL platforms, 160 for mobiles.
 * @param targetPpiY targeted pixel per inch ratio on Y axis. Usually about 96 for desktop and WebGL platforms, 160
 *            for mobiles.
 * @param aspectRatio width divided by height. Will preserve this aspect ratio by applying letterboxing. */
public LetterboxingViewport(final float targetPpiX, final float targetPpiY, final float aspectRatio) {
    super(Scaling.fit, 0f, 0f); // Temporary setting world size to mock values.
    this.targetPpiX = targetPpiX;
    this.targetPpiY = targetPpiY;
    this.aspectRatio = aspectRatio;
    updateScale();
    updateWorldSize();
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:14,代码来源:LetterboxingViewport.java

示例3: create

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
@Override
public void create () {
	batch = new SpriteBatch();
	font = new BitmapFont();
	stage = new Stage(new ScalingViewport(Scaling.fit, 24, 12));
	regions = new TextureRegion[8 * 8];
	sprites = new Sprite[24 * 12];

	texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
	for (int y = 0; y < 8; y++) {
		for (int x = 0; x < 8; x++) {
			regions[x + y * 8] = new TextureRegion(texture, x * 32, y * 32, 32, 32);
		}
	}

	Random rand = new Random();
	for (int y = 0, i = 0; y < 12; y++) {
		for (int x = 0; x < 24; x++) {
			Image img = new Image(regions[rand.nextInt(8 * 8)]);
			img.setBounds(x, y, 1, 1);
			stage.addActor(img);
			sprites[i] = new Sprite(regions[rand.nextInt(8 * 8)]);
			sprites[i].setPosition(x, y);
			sprites[i].setSize(1, 1);
			i++;
		}
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:29,代码来源:StagePerformanceTest.java

示例4: makeGameFileRow

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
private Table makeGameFileRow(final FileHandle gameSaveFile) {
	GameSave towerData;
	try {
		towerData = GameSaveFactory.readMetadata(gameSaveFile.read());
	} catch (Exception e) {
		Gdx.app.log(TAG, "Failed to parse file.", e);
		return null;
	}

	FileHandle imageFile = Gdx.files.external(TowerConsts.GAME_SAVE_DIRECTORY + gameSaveFile.name() + ".png");

	Actor imageActor = null;
	if (imageFile.exists()) {
		try {
			imageActor = new Image(loadTowerImage(imageFile), Scaling.fit, Align.top);
		} catch (Exception ignored) {
			imageActor = null;
		}
	}

	if (imageActor == null) {
		imageActor = FontManager.Default.makeLabel("No image.");
	}

	Table fileRow = new Table();
	fileRow.defaults().fillX().pad(Display.devicePixel(10)).space(Display.devicePixel(10));
	fileRow.row();
	fileRow.add(imageActor).width(Display.devicePixel(64)).height(Display.devicePixel(64)).center();
	fileRow.add(makeGameFileInfoBox(fileRow, gameSaveFile, towerData)).expandX().top();
	fileRow.row().fillX();
	fileRow.add(new HorizontalRule(Color.DARK_GRAY, 2)).colspan(2);

	return fileRow;
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:35,代码来源:LoadTowerWindow.java

示例5: createTable

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
/**
 * Erstellt die Tabelle.
 * 
 * @param loot
 *            das Loot
 * @param maxWidth
 *            die Breite
 */
private void createTable(final Lootable loot, final float maxWidth) {
	group = new Table();

	Drawable drawable = loot.getImage();
	Image img = new Image(drawable, Scaling.fit, Align.center);
	Label name;

	labelStyle = new LabelStyle(
			AssetManager.getHeadlineFont(FontSize.FORTY), Color.GRAY);
	name = new Label(loot.getName(), labelStyle);

	labelStyle.font = AssetManager.getTextFont(FontSize.FORTY);
	description = new Label(loot.getDescription(), labelStyle);
	description.setWidth(maxWidth - 260);
	description.setWrap(true);

	nameAndDescription = new Table();
	nameAndDescription.align(Align.left + Align.top);
	nameAndDescription.add(name).expandX().align(Align.left).spaceLeft(10);
	nameAndDescription.row();
	nameAndDescription.add(description).align(Align.left).spaceLeft(10)
			.width(maxWidth - 260);
	nameAndDescription.setSize(nameAndDescription.getPrefWidth(),
			nameAndDescription.getPrefHeight());

	group.add(img).size(200).pad(10, 0, 10, 10);
	group.add(nameAndDescription).pad(10, 0, 10, 0);
	group.pad(0);

	contentHeight = group.getPrefHeight() + 10;

	group.setSize(maxWidth, contentHeight);
	group.setBackground(new TextureRegionDrawable(AssetManager
			.getTextureRegion("ui", "panel_beige")));
}
 
开发者ID:PhilippGrulich,项目名称:HAW-SE2-projecthorse,代码行数:44,代码来源:LootItem.java

示例6: createHUD

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
protected void createHUD () {
	hud = new Stage(new ScalingViewport(Scaling.fit, PREF_HUDWIDTH, PREF_HUDHEIGHT));
	hudWidth = hud.getWidth();
	hudHeight = hud.getHeight();
	skin = new Skin(Gdx.files.internal("data/uiskin.json"));
	
	fpsLabel = new Label("FPS: 999", skin);
	hud.addActor(fpsLabel);
	
	vertexCountLabel = new Label("Vertices: 999", skin);
	vertexCountLabel.setPosition(0, fpsLabel.getTop());
	hud.addActor(vertexCountLabel);

	textureBindsLabel = new Label("Texture bindings: 999", skin);
	textureBindsLabel.setPosition(0, vertexCountLabel.getTop());
	hud.addActor(textureBindsLabel);

	shaderSwitchesLabel = new Label("Shader switches: 999", skin);
	shaderSwitchesLabel.setPosition(0, textureBindsLabel.getTop());
	hud.addActor(shaderSwitchesLabel);

	drawCallsLabel = new Label("Draw calls: 999", skin);
	drawCallsLabel.setPosition(0, shaderSwitchesLabel.getTop());
	hud.addActor(drawCallsLabel);

	glCallsLabel = new Label("GL calls: 999", skin);
	glCallsLabel.setPosition(0, drawCallsLabel.getTop());
	hud.addActor(glCallsLabel);

}
 
开发者ID:if1live,项目名称:amatsukaze,代码行数:31,代码来源:BaseGame.java

示例7: resize

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
@Override
public void resize(int width, int height) {
    WisperGame.Camera.zoom = 1f;
    WisperGame.Camera.updateViewport();

    ScalingViewport stageViewport = new ScalingViewport(
            Scaling.fit,
            WisperGame.VirtualViewport.getVirtualWidth(),
            WisperGame.VirtualViewport.getVirtualHeight(),
            WisperGame.Camera);

    stage.setViewport(stageViewport);
    stage.getViewport().update(width, height, true);
}
 
开发者ID:Drusy,项目名称:Wisper,代码行数:15,代码来源:LoadingScreen.java

示例8: resize

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
@Override
public void resize(int width, int height) {
    WisperGame.Camera.zoom = 1f;
    WisperGame.Camera.updateViewport();

    ScalingViewport stageViewport = new ScalingViewport(
            Scaling.fit,
            WisperGame.VirtualViewport.getVirtualWidth(),
            WisperGame.VirtualViewport.getVirtualHeight(),
            WisperGame.Camera);

    stage.setViewport(stageViewport);
    stage.getViewport().update(width, height, true);
    table.invalidateHierarchy();
}
 
开发者ID:Drusy,项目名称:Wisper,代码行数:16,代码来源:WisperChooseMenu.java

示例9: resize

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
@Override
public void resize(int width, int height) {
    WisperGame.Camera.zoom = Config.GAME_RATIO;
    WisperGame.Camera.updateViewport();

    ScalingViewport stageViewport = new ScalingViewport(
            Scaling.fit,
            WisperGame.VirtualViewport.getVirtualWidth(),
            WisperGame.VirtualViewport.getVirtualHeight(),
            WisperGame.Camera);

    stage.setViewport(stageViewport);
    stage.getViewport().update(width, height, true);
}
 
开发者ID:Drusy,项目名称:Wisper,代码行数:15,代码来源:GameScreen.java

示例10: h

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
h(q paramq, com.nianticproject.ingress.common.j.e parame, int paramInt)
{
  this.a = ((q)an.a(paramq));
  this.d = ((com.nianticproject.ingress.common.j.e)an.a(parame));
  this.b = new Image(null, Scaling.fit);
  this.e = paramInt;
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:8,代码来源:h.java

示例11: FitViewport

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
/** Creates a new viewport using a new {@link OrthographicCamera}. */
public FitViewport (float worldWidth, float worldHeight) {
	super(Scaling.fit, worldWidth, worldHeight);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:5,代码来源:FitViewport.java

示例12: AchievementListViewItem

import com.badlogic.gdx.utils.Scaling; //导入方法依赖的package包/类
public AchievementListViewItem(AchievementListView achievementListView, Achievement achievement, final Drawable itemSelectBackground) {
	this.achievementListView = achievementListView;

	row().pad(Display.devicePixel(16), Display.devicePixel(8), Display.devicePixel(16), Display.devicePixel(8)).fillX();
	add(FontManager.Roboto18.makeLabel(achievement.getName())).expandX().left();

	Actor actor;
	if (achievement.isCompleted()) {
		if (achievement.hasGivenReward()) {
			actor = FontManager.Roboto18.makeLabel("Completed!");
		} else {
			actor = FontManager.Roboto18.makeLabel("Tap to Complete!");
		}
	} else if (achievement.isLocked()) {
		actor = FontManager.Roboto18.makeLabel("Locked.");
	} else {
		actor = new ProgressBar(achievement.getPercentComplete());
	}
	add(actor).width(Display.devicePixel(200));

	Image arrowImg = new Image(TowerAssetManager.drawableFromAtlas("right-arrow", "hud/menus.txt"), Scaling.fit);
	add(arrowImg).width((int) arrowImg.getWidth());

	row().fillX();
	add(new HorizontalRule(Color.DARK_GRAY, 1)).expandX().colspan(3);

	addListener(new EventListener() {
		@Override
		public boolean handle(Event e) {
			if (!(e instanceof InputEvent)) {
				return false;
			}
			InputEvent event = (InputEvent) e;

			if (event.getType().equals(InputEvent.Type.touchDown)) {
				addAction(Actions.sequence(Actions.delay(0.125f), Actions.run(new Runnable() {
					@Override
					public void run() {
						setBackground(itemSelectBackground);
					}
				})));
			} else {
				clearActions();
				setBackground((Drawable) null);
			}

			return false;
		}
	});
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:51,代码来源:AchievementListViewItem.java


注:本文中的com.badlogic.gdx.utils.Scaling.fit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。