本文整理匯總了Java中com.badlogic.gdx.utils.viewport.ScreenViewport類的典型用法代碼示例。如果您正苦於以下問題:Java ScreenViewport類的具體用法?Java ScreenViewport怎麽用?Java ScreenViewport使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ScreenViewport類屬於com.badlogic.gdx.utils.viewport包,在下文中一共展示了ScreenViewport類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
@Override
public void start() {
finishedLoading = false;
stage = new Stage(new ScreenViewport());
skin = createSkin();
Image image= new Image(skin, "bg");
image.setScaling(Scaling.stretch);
image.setFillParent(true);
stage.addActor(image);
root = new Table();
root.setFillParent(true);
stage.addActor(root);
progressBar = new ProgressBar(0, 1, .01f, false, skin);
progressBar.setAnimateDuration(.1f);
root.add(progressBar).growX().expandY().pad(20.0f);
}
示例2: UiStage
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
public UiStage(){
OrthographicCamera _uiCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
this.setViewport(new ScreenViewport(_uiCamera));
// create skin
// root table
_rootTable = createRootTable();
createErrorMessagePanel();
uiPanel = new UIPanel(Assets._skin);
_rootTable.add(uiPanel)
.align(Align.center)
.fill(true , true)
.minWidth(uiPanel.getLeftSection().getPrefWidth() + uiPanel.getMidSection().getPrefWidth() + uiPanel.getRightSection().getPrefWidth() + 50);
// align stuff
_rootTable.align(Align.bottom);
// add root table to stage
this.addActor(_rootTable);
_pauseWindow = new PauseWindow("Pause", Assets._skin);
_pauseWindow.setSize(Gdx.graphics.getWidth() , Gdx.graphics.getHeight());
this.addActor(_pauseWindow);
this.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
示例3: initLoseStage
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
private void initLoseStage() {
setViewport(new ScreenViewport(getCamera()));
getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
getViewport().apply(true);
Label youLoseLbl = new Label("You lost" , Assets._skin , "fontVeraBd24" ,"white");
playAgainBtn = new TextButton("Play Again", Assets._skin , "menu");
mainMenuBtn = new TextButton("Main Menu", Assets._skin , "menu");
Table container = new Table(Assets._skin);
youLoseLbl.setColor(Color.RED);
container.add(youLoseLbl).spaceBottom(100).row();
container.add(playAgainBtn).align(Align.left).spaceBottom(20).row();
container.add(mainMenuBtn).align(Align.left);
container.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
container.setFillParent(true);
addActor(container);
}
示例4: initWinStage
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
private void initWinStage() {
setViewport(new ScreenViewport(getCamera()));
getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
getViewport().apply(true);
Label youWinLabel = new Label("You Won!" , Assets._skin , "fontVeraBd24" , "white");
playAgainBtn = new TextButton("Play Again", Assets._skin , "menu");
mainMenuBtn = new TextButton("Main Menu", Assets._skin , "menu");
Table container = new Table(Assets._skin);
youWinLabel.setColor(Color.GREEN);
container.add(youWinLabel).spaceBottom(100).row();
container.add(playAgainBtn).align(Align.left).spaceBottom(20).row();
container.add(mainMenuBtn).align(Align.left);
container.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
container.setFillParent(true);
addActor(container);
}
示例5: MenuScreen
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
public MenuScreen(MainGameClass game) {
this.game = game;
stage = new Stage(new ScreenViewport());
Gdx.input.setInputProcessor(stage);
skin = new Skin(Gdx.files.internal("skins/Flat_Earth_UI_Skin/flatearthui/flat-earth-ui.json"));
progressBarStyle = skin.get("fancy", ProgressBar.ProgressBarStyle.class);
TiledDrawable tiledDrawable = skin.getTiledDrawable("slider-fancy-knob").tint(skin.getColor("selection"));
tiledDrawable.setMinWidth(0);
progressBarStyle.knobBefore = tiledDrawable;
sliderStyle = skin.get("fancy", Slider.SliderStyle.class);
sliderStyle.knobBefore = tiledDrawable;
layoutTable = new Table();
layoutTable.top();
layoutTable.setFillParent(true);
layoutTable.pad(getPixelSizeFromDensityIndependentPixels(50));
}
示例6: DungeonScreen
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
public DungeonScreen(final PMD game) {
//init rendering stuff first
this.game = game;
this.batch = game.batch;
this.skin = new Skin(Gdx.files.internal("ui/skin/flat-earth-ui.json"));
sRenderer = new ShapeRenderer();
this.renderList = new Array<RenderComponent>();
cameraBounds = new Rectangle();
gameCamera = new OrthographicCamera(Gdx.graphics.getWidth() / PPM, Gdx.graphics.getHeight() / PPM);
gamePort = new ScreenViewport(gameCamera);
gamePort.setUnitsPerPixel(1 / PPM);
//init stuff for updating
controller = new Controller(this);
tileBoard = controller.floor.tileBoard;
bFont = new BitmapFont(Gdx.files.internal("ui/myCustomFont.fnt"));
bFont.getData().setScale(.5f);
hud = new Hud(controller, skin, batch);
pauseMenu = new PauseMenu(controller, skin, batch);
}
示例7: MenuScreen
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
public MenuScreen(String menuTitle) {
this.camera = new OrthographicCamera();
camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
this.stage = new Stage(new ScreenViewport(camera));
table = new Table();
table.setFillParent(true);
table.defaults().expand().fill().pad(0);
skin = Utils.UI_SKIN;
table.setBackground(skin.getDrawable("menu-background"));
title = new Label(menuTitle, skin, "large");
title.setAlignment(Align.center);
table.add(title).padTop(275).colspan(2).row();
stage.addActor(table);
// stage.setDebugAll(true);
}
示例8: create
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
@Override
public void create () {
Gdx.app.log("ShapeClearGame", "create()");
Localize.setLanguage(Locale.getDefault());
AssetLoader.load();
viewport=new ScreenViewport();
stage=new Stage(viewport);
background=new Background();
fpsCounter=new FPSCounter();
resize(Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
mainMenu=new MainMenu(this);
gameScreen=new GameScreen(this);
setScreen(mainMenu);
}
示例9: MainScreen
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
public MainScreen(SkinEditorGame game) {
this.game = game;
barMenu = new MenuBar(game);
barWidgets = new WidgetsBar(game);
panePreview = new PreviewPane(game, this);
paneOptions = new OptionsPane(game, panePreview);
CB_SpriteBatch batch = new CB_SpriteBatch(CB_SpriteBatch.Mode.NORMAL);
stage = new Stage(new ScreenViewport(),batch);
Table table = new Table();
table.setFillParent(true);
table.top().left().add(barMenu).expandX().fillX().colspan(2).row();
table.top().left().add(barWidgets).expandX().fillX().colspan(2).row();
table.top().left().add(paneOptions).width(420).left().fill().expandY();
ScrollPane scrollPane = new ScrollPane(panePreview);
table.add(scrollPane).fill().expand();
stage.addActor(table);
barWidgets.initializeButtons();
}
示例10: Gui
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
public Gui(SpriteAnimator spriteAnimator) {
super(new ScreenViewport());
style = new Label.LabelStyle(font, Color.BLACK);
frameSpeed = new Label("", style);
frameSpeed.setPosition(1f, 10f);
updateFrameSpeed(spriteAnimator.getFrameSpeed());
addActor(frameSpeed);
frames = new Label("", style);
frames.setPosition(1f, 25f);
updateFrames(spriteAnimator.getFrames());
addActor(frames);
row = new Label("", style);
row.setPosition(1f, 40f);
updateRow(spriteAnimator.getRow());
addActor(row);
zoomLevel = new Label("", style);
zoomLevel.setPosition(1f, 55f);
updateZoom(spriteAnimator.getZoom());
addActor(zoomLevel);
}
示例11: RavUI
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
/**
* @param path - the path to the skin
*/
public RavUI (String path) {
if (!VisUI.isLoaded())
if(path.length() > 0)
VisUI.load(path);
else
VisUI.load();
screenStage = new Stage(new ScreenViewport());
debugConsole = new DebugConsole();
RavTech.input.addInputProcessor(screenStage);
screenStage.addListener(new InputListener() {
@Override
public boolean keyDown (InputEvent event, int key) {
if (key == Keys.F1)
debugConsole.toggleVisible();
return true;
}
});
screenStage.addActor(debugConsole);
}
示例12: HUD
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
public HUD()
{
score = -1;
Table table = new Table();
table.top();
table.setFillParent(true);
//viewport = new ScreenViewport(FlappyDemo.WIDTH, FlappyDemo.HEIGHT, new OrthographicCamera());
viewport = new ScreenViewport(new OrthographicCamera());
scoreLabel = new Label(String.format("%d", score), new Label.LabelStyle(new BitmapFont(), Color.BLACK));
stage = new Stage(viewport);
table.add(scoreLabel).expandX().padTop(10);
// You can use table.row(); to create a new row
stage.addActor(table);
}
示例13: init
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
public void init(){
stage = new Stage(new ScreenViewport());
Gdx.input.setInputProcessor(stage);
mainTable = new Table();
mainTable.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
stage.addActor(mainTable);
font = new BitmapFont(Gdx.files.internal("font2.fnt"));
blueTextButtonStyle = new TextButtonStyle();
blueTextButtonStyle.up = TextureUtils.createDrawable(new Color(52f / 255f, 73f / 255f, 94f / 255f, 1.0f), 300, 75);
blueTextButtonStyle.down = TextureUtils.createDrawable(new Color(44f / 255f, 62f / 255f, 80f / 255f, 1.0f), 300, 75);
blueTextButtonStyle.over = TextureUtils.createDrawable(new Color(60f / 255f, 84f / 255f, 108f / 255f, 1.0f), 300, 75);
blueTextButtonStyle.font = font;
blueTextButtonStyle.fontColor = Color.BLACK;
labelStyle = new LabelStyle();
labelStyle.background = blueTextButtonStyle.up;
labelStyle.font = font;
labelStyle.fontColor = Color.WHITE;
}
示例14: create
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
@Override
public void create() {
engine = new ExamplesEngine();
entitas = new Entitas();
preferencesManager.LOG_LEVEL = LogManager.LOG_DEBUG;
AssetManager assetsManager = new AssetManager(new TestFileHandleResolver());
engine.addManager(new AssetsManagerGDX(assetsManager, preferencesManager));
engine.addManager(new PhysicsManagerGDX(new Vector2(0,-9.8f)));
engine.addManager(new GUIManagerGDX(new ScreenViewport(),new BitmapFont(), engine));
engine.addManager(new SceneManagerGDX(engine, entitas));
engine.addManager(new LogManagerGDX(preferencesManager));
engine.addManager(new InputManagerGDX(entitas, engine));
engine.addManager(preferencesManager);
game = new ExamplesGame(engine, new EventBusGDX(new MBassador()));
game.init();
game.pushState(new PlatformExampleState(engine, entitas));
}
示例15: show
import com.badlogic.gdx.utils.viewport.ScreenViewport; //導入依賴的package包/類
@Override
public void show() {
iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);
renderer = new ShapeRenderer();
renderer.setAutoShapeType(true);
// TODO: Initialize the HUD viewport
hudViewport = new ScreenViewport();
// TODO: Initialize the SpriteBatch
batch = new SpriteBatch();
// TODO: Initialize the BitmapFont
font = new BitmapFont();
// TODO: Give the font a linear TextureFilter
font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
player = new Player(iciclesViewport);
icicles = new Icicles(iciclesViewport);
// TODO: Set top score to zero
topScore = 0;
}