本文整理汇总了Java中com.badlogic.gdx.utils.viewport.ScalingViewport类的典型用法代码示例。如果您正苦于以下问题:Java ScalingViewport类的具体用法?Java ScalingViewport怎么用?Java ScalingViewport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScalingViewport类属于com.badlogic.gdx.utils.viewport包,在下文中一共展示了ScalingViewport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getViewports
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的package包/类
static public Array<Viewport> getViewports (Camera camera) {
int minWorldWidth = 640;
int minWorldHeight = 480;
int maxWorldWidth = 800;
int maxWorldHeight = 480;
Array<Viewport> viewports = new Array();
viewports.add(new StretchViewport(minWorldWidth, minWorldHeight, camera));
viewports.add(new FillViewport(minWorldWidth, minWorldHeight, camera));
viewports.add(new FitViewport(minWorldWidth, minWorldHeight, camera));
viewports.add(new ExtendViewport(minWorldWidth, minWorldHeight, camera));
viewports.add(new ExtendViewport(minWorldWidth, minWorldHeight, maxWorldWidth, maxWorldHeight, camera));
viewports.add(new ScreenViewport(camera));
ScreenViewport screenViewport = new ScreenViewport(camera);
screenViewport.setUnitsPerPixel(0.75f);
viewports.add(screenViewport);
viewports.add(new ScalingViewport(Scaling.none, minWorldWidth, minWorldHeight, camera));
return viewports;
}
示例2: create
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的package包/类
@Override
public void create() {
//Init statics
OBJECT_ID = 0;
LoaderUtils loaderUtils = new LoaderUtils();
loaderUtils.init();
//Init cameras and controllers
ScreenViewport viewportGUI = new ScreenViewport(new OrthographicCamera());
CameraController oCameraGUI = new CameraController(viewportGUI);
oCameraGUI.getViewport().apply(true);
ScalingViewport viewportPlay = new ScalingViewport(Scaling.fillY, TARGET_WIDTH, TARGET_HEIGHT);
CameraController oCameraPlay = new CameraController(viewportPlay);
oCameraPlay.setBoundaries(worldBoundaries);
SpriteBatch batch = new SpriteBatch();
Stage playStage = new Stage(viewportPlay, batch);
Stage guiStage = new Stage(viewportGUI, batch);
InputController oInputCtrl = new InputController(playStage, guiStage);
PhysicsController physicsCtrl = new PhysicsController(oCameraPlay, TIME_STEP, 1, 1);
EngineController oEngineCtrl = new EngineController(playStage, guiStage, physicsCtrl, oInputCtrl, oCameraPlay, loaderUtils);
GUIController oGuiController = new GUIController(oCameraGUI, oCameraPlay, oInputCtrl, guiStage, loaderUtils);
MapController oMapController = new MapController(oEngineCtrl, oCameraPlay);
oMapController.loadMap("data/gameMap.tmx", batch, true);
//Set camera listener, for camera control
Scene2dListenersUtils.setupPlayStageCameraListener(playStage, oCameraPlay, oInputCtrl);
//Set screen
mainScreen = new MainScreen(oEngineCtrl, oInputCtrl, oCameraGUI, oCameraPlay, oGuiController);
this.setScreen(mainScreen);
}
示例3: create
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的package包/类
@Override
public void create() {
Gdx.graphics.setContinuousRendering(false);
final Viewport viewport = new ScalingViewport(Scaling.stretch, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), new OrthographicCamera());
final Batch batch = new SpriteBatch();
final Splash splash = new Splash(new Splash.LoadReady() {
@Override
public void ready() {
Config.AppRaterlaunchCount.setValue(Config.AppRaterlaunchCount.getValue() + 1);
Config.AcceptChanges();
// Splash is ready with initialisation
// now switch Stage to ViewManager
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
StageManager.setMainStage(new ViewManager(
CacheboxMain.this, StageManager.viewport, StageManager.batch));
batch.dispose();
}
});
}
}, viewport, batch);
StageManager.setMainStage(splash);
Gdx.graphics.requestRendering();
CB.initThreadCheck();
}
示例4: createStage
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的package包/类
public static Stage createStage(float vp_width, float vp_height)
{
Stage stage = new Stage(new ScalingViewport(Scaling.fill, vp_width, vp_height));
stage.getViewport().setCamera(new OrthographicCamera(vp_width, vp_height));
((OrthographicCamera) stage.getCamera()).position.set(((OrthographicCamera) stage.getCamera()).viewportWidth / 2, ((OrthographicCamera) stage.getCamera()).viewportHeight / 2, 0f);
((OrthographicCamera) stage.getCamera()).zoom = 1f;
((OrthographicCamera) stage.getCamera()).update();
return stage;
}
示例5: CameraSystem
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的package包/类
public CameraSystem(float viewportWidth, float viewportHeight) {
camera = new OrthographicCamera(viewportWidth, viewportHeight);
viewport = new ScalingViewport(Scaling.stretch, viewportWidth,
viewportHeight, camera);
addParalaxLayer(0, 0.0f);
addParalaxLayer(1, 0.10f);
addParalaxLayer(2, 0.50f);
}
示例6: create
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的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++;
}
}
}
示例7: render
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的package包/类
public void render () {
batch.setProjectionMatrix(camera.projection);
batch.setTransformMatrix(camera.view);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
// draw a white background so we are able to see the black bars
batch.setColor(1, 1, 1, 1);
batch.draw(texture, -4096, -4096, 4096, 4096, 8192, 8192, 1, 1, 0, 0, 0, 16, 16, false, false);
batch.setColor(1, 0, 0, 1);
batch.draw(texture, 150, 100, 16, 16, 32, 32, 1, 1, 45, 0, 0, 16, 16, false, false);
font.draw(batch, viewport.getClass().getSimpleName(), 150, 100);
batch.end();
if (viewport instanceof ScalingViewport) {
// This shows how to set the viewport to the whole screen and draw within the black bars.
ScalingViewport scalingViewport = (ScalingViewport)viewport;
int screenWidth = Gdx.graphics.getWidth();
int screenHeight = Gdx.graphics.getHeight();
Gdx.gl.glViewport(0, 0, screenWidth, screenHeight);
batch.getProjectionMatrix().idt().setToOrtho2D(0, 0, screenWidth, screenHeight);
batch.getTransformMatrix().idt();
batch.begin();
float leftGutterWidth = scalingViewport.getLeftGutterWidth();
if (leftGutterWidth > 0) {
batch.draw(texture, 0, 0, leftGutterWidth, screenHeight);
batch.draw(texture, scalingViewport.getRightGutterX(), 0, scalingViewport.getRightGutterWidth(), screenHeight);
}
float bottomGutterHeight = scalingViewport.getBottomGutterHeight();
if (bottomGutterHeight > 0) {
batch.draw(texture, 0, 0, screenWidth, bottomGutterHeight);
batch.draw(texture, 0, scalingViewport.getTopGutterY(), screenWidth, scalingViewport.getTopGutterHeight());
}
batch.end();
viewport.update(screenWidth, screenHeight, true); // Restore viewport.
}
}
示例8: GameStage
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的package包/类
public GameStage() {
super(new ScalingViewport(Scaling.stretch, VIEWPORT_WIDTH, VIEWPORT_HEIGHT,
new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT)));
setUpCamera();
setUpStageBase();
setUpGameLabel();
setUpMainMenu();
setUpTouchControlAreas();
Gdx.input.setInputProcessor(this);
AudioUtils.getInstance().init();
onGameOver();
}
示例9: BaseScreen
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的package包/类
public BaseScreen(MissingWords missingWords) {
this.missingWords = missingWords; // Conectamos el juego con la pantalla base
this.myBatch = missingWords.getSB();
/*
* Con Scaling.stretch ajustamos la aplicaci�n a la pantalla, estrechando
* si es necesario.
*/
viewport = new ScalingViewport(Scaling.stretch,
MissingWords.VIEWPORT_WIDTH , MissingWords.VIEWPORT_HEIGHT);
stage = new Stage(viewport, myBatch);
}
示例10: createHUD
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的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);
}
示例11: createStage
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的package包/类
/**
* Creates a Stage as in {@link Stage#Stage()}, but using
* {@link PolygonSpriteBatch} instead of {@link SpriteBatch}
*
* PolygonSpriteBatch must be used for
* {@link es.eucm.ead.engine.components.renderers.SpineActor} to work
* properly.
*/
protected Stage createStage() {
Viewport viewport = new ScalingViewport(Scaling.stretch,
Gdx.graphics.getWidth(), Gdx.graphics.getHeight(),
new OrthographicCamera());
PolygonSpriteBatch batch = new PolygonSpriteBatch();
Stage newStage = new Stage(viewport, batch);
return newStage;
}
示例12: resize
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的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);
}
示例13: resize
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的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();
}
示例14: resize
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的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);
}
示例15: createStage
import com.badlogic.gdx.utils.viewport.ScalingViewport; //导入依赖的package包/类
private static CustomStage createStage()
{
return new CustomStage(new ScalingViewport(Scaling.stretch, Settings.GAME_WIDTH, Settings.GAME_HEIGHT));
}