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


Java ScalingViewport类代码示例

本文整理汇总了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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:22,代码来源:ViewportTest1.java

示例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);
}
 
开发者ID:unlimitedggames,项目名称:gdxjam-ugg,代码行数:34,代码来源:GDXJam.java

示例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();
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:33,代码来源:CacheboxMain.java

示例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;
}
 
开发者ID:kLeZ,项目名称:LibGDX-MVC-Tutorial,代码行数:10,代码来源:StageComponent.java

示例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);
}
 
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:10,代码来源:CameraSystem.java

示例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++;
		}
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:29,代码来源:StagePerformanceTest.java

示例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.
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:40,代码来源:ViewportTest2.java

示例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();
}
 
开发者ID:wmora,项目名称:martianrun,代码行数:13,代码来源:GameStage.java

示例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);
}
 
开发者ID:adrianoubk,项目名称:Missing_Words,代码行数:14,代码来源:BaseScreen.java

示例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);

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

示例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;
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:17,代码来源:EngineApplicationListener.java

示例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);
}
 
开发者ID:Drusy,项目名称:Wisper,代码行数:15,代码来源:LoadingScreen.java

示例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();
}
 
开发者ID:Drusy,项目名称:Wisper,代码行数:16,代码来源:WisperChooseMenu.java

示例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);
}
 
开发者ID:Drusy,项目名称:Wisper,代码行数:15,代码来源:GameScreen.java

示例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));
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:5,代码来源:Assets.java


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