本文整理匯總了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);
}
示例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();
}
示例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++;
}
}
}
示例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;
}
示例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")));
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
});
}