本文整理汇总了Java中com.badlogic.gdx.utils.viewport.FitViewport类的典型用法代码示例。如果您正苦于以下问题:Java FitViewport类的具体用法?Java FitViewport怎么用?Java FitViewport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FitViewport类属于com.badlogic.gdx.utils.viewport包,在下文中一共展示了FitViewport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MenuScreen
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
/**
* Menu Screen's constructor.
* It initializes all the Menu elements.
*
* @param game The current game session.
*/
protected MenuScreen(final Armadillo game) {
this.game = game;
batch = game.getBatch();
gameServices = game.getGameServices();
skin1 = game.getPrimarySkin();
skin2 = game.getSecondarySkin();
viewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
viewport.apply();
stage = new Stage(viewport, batch);
backgroundImg = new Image(game.getAssetManager().get("background.png", Texture.class));
backgroundImg.setScale(VIEWPORT_WIDTH / backgroundImg.getWidth(), VIEWPORT_HEIGHT / backgroundImg.getHeight());
titleImg = new Image(game.getAssetManager().get("armadillo_title.png", Texture.class));
titleImg.setSize(0.8f * titleImg.getWidth(), 0.8f * titleImg.getHeight());
titleImg.setPosition(VIEWPORT_WIDTH / 2 - titleImg.getWidth() / 2, VIEWPORT_HEIGHT * 0.98f - titleImg.getHeight());
}
示例2: show
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
@Override
public void show()
{
fpsLogger = new FPSLogger();
batch = new SpriteBatch();
camera = new OrthographicCamera(500, 800);
viewport = new FitViewport(500, 800, camera);
player = new Player();
player.create();
background = new Background();
background.create();
spawningFactory = new SpawningFactory();
spawningFactory.create();
spawningEnemy = new SpawningEnemy();
spawningEnemy.create();
spawningBullet = new SpawningBullet();
spawningBullet.create();
ui = new UI();
ui.create();
}
示例3: MenuScreen
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
public MenuScreen() {
camera = new OrthographicCamera();
viewport = new FitViewport(Game.WIDTH, Game.HEIGHT, camera);
viewport.apply();
camera.position.set(Game.WIDTH / 2, Game.HEIGHT / 2, 0);
camera.update();
betaText = new BitmapFont(Gdx.files.internal("score.fnt"), Gdx.files.internal("score.png"), false);
betaText.getData().setScale(0.35f);
logo = new Sprite(new Texture("logo.png"));
Random r = new Random();
background = new Particle[r.nextInt(55 - 45) + 45];
for (int i = 0; i < background.length; i++) {
int size = r.nextInt(4) + 1;
int x = r.nextInt(Game.WIDTH);
int y = r.nextInt(Game.HEIGHT);
background[i] = new Particle(x, y, 0, 0, -1, new Color(207 / 255f, 187 / 255f, 20 / 255f, 1f), size);
}
musicMuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_muted.png")));
musicUnmuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_unmuted.png")));
play = new CenteredButton(500, "buttons/play.png");
music = new Button(Game.WIDTH - 130, 15, Game.musicMuted() ? musicMuted : musicUnmuted);
music.setScale(4f);
}
示例4: init
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
public static void init(DSGame game) {
OPT = new PreferenceAssist();
if(app_orientation == LANDSCAPE) {
T_HEIGHT = 1080;
T_WIDTH = 1920;
} else {
T_WIDTH = 1080;
T_HEIGHT = 1920;
// T_WIDTH = 720;
// T_HEIGHT = 1280;
}
camera = new OrthographicCamera();
camera.position.set((int)(DS.T_WIDTH/2.0), (int)(DS.T_HEIGHT/2.0), 0);
viewport = new FitViewport(DS.T_WIDTH, DS.T_HEIGHT, camera);
DS.game = game;
sb = new SpriteBatch(150);
Gdx.app.setLogLevel(Application.LOG_DEBUG);
}
示例5: show
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
public void show() {
if (!init) {
loadingScreenAssets = new Assets.LoadingScreenAssets();
AL.getAssetManager().loadAssetFields(loadingScreenAssets);
AL.getAssetManager().finishLoading();
font = new BitmapFont();
batch = new SpriteBatch();
cam = new OrthographicCamera();
viewport = new FitViewport(1920, 1080);
viewport.setCamera(cam);
stage = new Stage(viewport);
stage.setViewport(viewport);
skin = loadingScreenAssets.styles_json;
loadingScreenBar = new ProgressBar(0, 100, 1, false, skin);
loadingScreenBar.setPosition(25, -10);
loadingScreenBar.setSize(1890, 50);
stage.addActor(loadingScreenBar);
}
init = true;
}
示例6: show
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
/**
* Method responsible for initializing the main menu
* Called when the screen becomes the current screen of the game
*/
@Override
public void show() {
AL.getAudioManager().registerMusic("bitrush", menuAssets.bitrush);
AL.getAudioManager().playMusic("bitrush");
cam = new OrthographicCamera();
viewport = new FitViewport(1920, 1080);
viewport.setCamera(cam);
stage = new Stage(viewport);
stage.setViewport(viewport);
skin = menuAssets.styles_json;
skin.getFont("bocklin").getData().setScale(0.8f, 0.8f);
int x = 1920;
int y = 1080;
spriteBatch = new SpriteBatch();
mainbackground = menuAssets.testmainscreen;
initButtons();
AL.input.setInputProcessor(stage);
}
示例7: show
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
/**
* Method responsible for initializing the main menu
* Called when the screen becomes the current screen of the game
*/
@Override
public void show() {
cam = new OrthographicCamera();
viewport = new FitViewport(1920, 1080);
viewport.setCamera(cam);
stage = new Stage(viewport);
stage.setViewport(viewport);
skin = settingsAssets.styles_json;
int x = 1920;
int y = 1080;
spriteBatch = new SpriteBatch();
mainbackground = settingsAssets.testmainscreen;
BitmapFont font = settingsAssets.bocklin_fnt;
TextureRegion backgroundTexture = new TextureRegion(settingsAssets.background_textbutton);
inputTable = new Table();
keys = IInputConfig.InputKeys.values();
keyMap = new HashMap<>();
initInputRows(font, backgroundTexture);
createBackButton();
AL.input.setInputProcessor(new InputMultiplexer(stage, this));
}
示例8: show
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
/**
* Method responsible for initializing the GameOverScreen
* Called when the screen becomes the current screen of the game
*/
@Override
public void show() {
cam = new OrthographicCamera();
viewport = new FitViewport(1920, 1080);
viewport.setCamera(cam);
stage = new Stage(viewport);
stage.setViewport(viewport);
skin = menuAssets.styles_json;
skin.getFont("bocklin").getData().setScale(0.8f, 0.8f);
int x = 1920;
int y = 1080;
spriteBatch = new SpriteBatch();
mainbackground = menuAssets.testmainscreen;
createComponents();
AL.input.setInputProcessor(stage);
}
示例9: show
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
/**
* Method responsible for initializing the pause menu
* Called when the screen becomes the current screen of the game
*/
@Override
public void show() {
// Inits:
cam = new OrthographicCamera();
viewport = new FitViewport(1920, 1080);
viewport.setCamera(cam);
stage = new Stage(viewport);
stage.setViewport(viewport);
skin = menuAssets.styles_json;
skin.getFont("bocklin").getData().setScale(0.8f, 0.8f);
int x = 1920;
int y = 1080;
spriteBatch = new SpriteBatch();
mainbackground = menuAssets.testmainscreen;
createComponents();
AL.input.setInputProcessor(new InputMultiplexer(stage, this));
}
示例10: RenderSystem
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
public RenderSystem(DecalBatch decalBatch, AssetManager assetManager, float worldDegree, Assets.LevelAssets assets) {
super(Aspect.all(RenderComponent.class, PositionComponent.class));
this.levelAssets = assets;
decalMap = new ObjectMap<>();
uiMap = new ObjectMap<>();
this.decalBatch = decalBatch;
this.assetManager = assetManager;
buffers = new ObjectMap<>();
this.spriteBatch = new SpriteBatch();
this.font = assets.uifont;
font.setColor(Color.BLACK);
this.uiCamera = new OrthographicCamera();
Viewport viewportUi = new FitViewport(levelAssets.health_bar_gradient.getWidth(), levelAssets.health_bar_gradient.getHeight(), uiCamera);
viewportUi.update(viewportUi.getScreenWidth(), viewportUi.getScreenHeight(), true);
stateTime = 0;
this.worldDegree = worldDegree;
gradientShader = new ShaderProgram(Shaders.GradientShader.vertexShader, Shaders.GradientShader.fragmentShader);
if (gradientShader.isCompiled() == false)
throw new IllegalArgumentException("couldn't compile shader: " + gradientShader.getLog());
shaderBatch = new SpriteBatch(10, gradientShader);
}
示例11: Hud
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
public Hud(SpriteBatch sb) {
countKill = 0;
viewport = new FitViewport(ScreenConf.V_WIDTH, ScreenConf.V_HEIGHT, new OrthographicCamera());
stage = new Stage(viewport, sb);
Table table = new Table();
table.setFillParent(true);
table.top();
countKillLabel = new Label(String.format("%03d", countKill), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
table.add(countKillLabel).expandX().padTop(10);
table.add().expandX();
table.add().expandX();
table.add().expandX();
stage.addActor(table);
}
示例12: create
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
@Override
public void create() {
if (androidInterface != null)
androidInterface.tryToStopMusicApp();
batch = new SpriteBatch();
sr = new ShapeRenderer();
camera = new OrthographicCamera();
viewport = new FitViewport(Configuration.WINDOW_WIDTH, Configuration.WINDOW_HEIGHT, camera);
camera.position.set(viewport.getWorldWidth() / 2 - (viewport.getWorldWidth() - 500) / 2, viewport.getWorldHeight() / 2 - (viewport.getWorldHeight() - 220) / 2, 0);
camera.update();
fade = new Sprite(new Texture("sprites/fade.png"));
fade.setBounds(0, -100, viewport.getWorldWidth(), viewport.getWorldHeight() - 40);
font = new BitmapFont(Gdx.files.internal("fonts/amiga4everpro2.fnt"));
showModernTimesCutscene(); // start the game
}
示例13: LogoScreen
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
public LogoScreen(SpriteBatch batch, ShapeRenderer shapeRenderer, FitViewport viewport, OrthographicCamera camera) {
this.batch = batch;
this.shapeRenderer = shapeRenderer;
this.viewport = viewport;
this.camera = camera;
spriteThere = new Sprite(new Texture("there.png"));
spriteFactory = new Sprite(new Texture("factory.png"));
spriteLibGdxLogo = new Sprite(new Texture("libgdx.png"));
AssetManager am = JewelThief.getInstance().getAssetManager();
am.load("audio/sounds/keyboard.ogg", Sound.class);
am.load("audio/sounds/keyboard_go_back.ogg", Sound.class);
am.load("audio/sounds/re.ogg", Sound.class);
am.load("audio/sounds/libgdx.ogg", Music.class);
am.finishLoading();
soundTypeTheRefactory = am.get("audio/sounds/keyboard.ogg", Sound.class);
soundGoBackOnKeyboard = am.get("audio/sounds/keyboard_go_back.ogg", Sound.class);
soundTypeRe = am.get("audio/sounds/re.ogg", Sound.class);
musicLibGdxJingle = am.get("audio/sounds/libgdx.ogg", Music.class);
resetAnimation();
}
示例14: OptionsScreen
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
public OptionsScreen(Launcher launcher) {
this.launcher = launcher;
viewport = new FitViewport(1920, 1080);
camera = new OrthographicCamera();
stage = new Stage(viewport, launcher.batch);
skin = new Skin(Gdx.files.internal("gfx/skin/uiskin.json"));
menu = new TextButton("MENU", skin, "default");
menu.setPosition(32, 48);
menu.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
launcher.setScreen(new MenuScreen(launcher));
}
});
stage.addActor(menu);
Gdx.input.setInputProcessor(stage);
}
示例15: MapGenDebugRenderer
import com.badlogic.gdx.utils.viewport.FitViewport; //导入依赖的package包/类
public MapGenDebugRenderer(GameMap map) {
this.map = map;
boundingBox = map.boundingBox;
Vector2 boundingBoxCenter = new Vector2();
boundingBox.getCenter(boundingBoxCenter);
int boundingBoxWidth = ((int) boundingBox.width);
int boundingBoxHeight = ((int) boundingBox.height);
camera = new OrthographicCamera(boundingBoxWidth + CAMERA_OFFSET, boundingBoxHeight + CAMERA_OFFSET);
camera.position.x = boundingBoxCenter.x;
camera.position.y = boundingBoxCenter.y;
camera.update();
shapeRenderer = new ShapeRenderer();
shapeRenderer.setProjectionMatrix(camera.combined);
viewport = new FitViewport(boundingBoxWidth, boundingBoxHeight, camera);
}