本文整理汇总了Java中com.badlogic.gdx.utils.viewport.Viewport类的典型用法代码示例。如果您正苦于以下问题:Java Viewport类的具体用法?Java Viewport怎么用?Java Viewport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Viewport类属于com.badlogic.gdx.utils.viewport包,在下文中一共展示了Viewport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RenderSystem
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的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);
}
示例2: RestartHud
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public RestartHud(final Application app, Viewport viewport, SpriteBatch batch, final Player player, final Ball ball, final TextureAtlas atlas)
{
super(viewport, batch);
gameOverLabel = new GameOverLabel();
restartButton = new RestartButton(player, ball, atlas);
score = new Score();
highScore = new HighScore(app);
homeButton = new HomeButton(app, atlas);
gameOverLabel.getLabel().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 + 350, Align.center);
restartButton.getButton().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 + 100, Align.center);
homeButton.getButton().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 - 25, Align.top);
score.getLabel().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 - 300, Align.center);
highScore.getLabel().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 - 500, Align.center);
actors.add(gameOverLabel.getLabel());
actors.add(restartButton.getButton());
actors.add(homeButton.getButton());
actors.add(score.getLabel());
actors.add(highScore.getLabel());
addAllActorsToStage();
}
示例3: MenuScreen
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public MenuScreen(Viewport viewport, Skin skin) {
this.viewport = viewport;
this.skin = skin;
this.WIDTH = Gdx.graphics.getWidth();
this.HEIGHT = Gdx.graphics.getHeight();
this.buttonWidth = WIDTH / 2 - 120;
stage = new Stage(viewport);
background = new Texture(Gdx.files.internal("screen.png"));
btnStartInactive = new Texture(Gdx.files.internal("btn-start-game.png"));
btnStartActive = new Texture(Gdx.files.internal("btn-start-game-active.png"));
btnCampaignInactive = new Texture(Gdx.files.internal("btn-campaign.png"));
btnSettingsInactive = new Texture(Gdx.files.internal("btn-settings.png"));
btnSettingsActive = new Texture(Gdx.files.internal("btn-settings-active.png"));
btnQuitInactive = new Texture(Gdx.files.internal("btn-quit.png"));
btnQuitActive = new Texture(Gdx.files.internal("btn-quit-active.png"));
}
示例4: SettingScreenOld
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public SettingScreenOld(Viewport viewport, Skin skin) {
float screenWidth = Gdx.graphics.getWidth();
float screenHeight = Gdx.graphics.getHeight();
stage = new Stage(viewport);
Label label = new Label("Player 1", skin);
label.setPosition(screenWidth / 2, screenHeight - 10, Align.top);
stage.addActor(label);
label = new Label("Forward", skin);
label.setPosition(10, screenHeight - 60);
stage.addActor(label);
TextField field = new TextField("", skin);
field.setPosition(50, screenHeight - 20);
field.setWidth(100);
field.setHeight(50);
stage.addActor(field);
}
示例5: GameContext2DImpl
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public GameContext2DImpl(ViewportFactory viewportFactory, ShaderConfig shaderConfig) {
camera = new OrthographicCamera();
world = new GameWorld(camera);
behaviorManager = new BehaviorManager();
batch = new SpriteBatch();
input = new InputMultiplexer();
boxWorld = new World(Vector2.Zero, false);
lightingManager = new LightingManager(boxWorld, camera);
renderManager = new GameObjectRenderManager(batch);
gameCamera = new VectorGameCamera(camera);
particleManager = new ParticleManager();
stage = new Stage(viewportFactory.create(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
Viewport worldStageViewport = viewportFactory.create(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
worldStageViewport.setCamera(camera);
worldStage = new Stage(worldStageViewport);
renderPipeline = new CombinedRenderPipelineFactory(shaderConfig, world, lightingManager, stage, worldStage, viewportFactory)
.create();
tiledMapManager = new TiledMapManagerImpl(behaviorManager, world, renderManager);
wire();
}
示例6: getFrameBufferPixmap
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public Pixmap getFrameBufferPixmap(Viewport viewport) {
int w = viewport.getScreenWidth();
int h = viewport.getScreenHeight();
int x = viewport.getScreenX();
int y = viewport.getScreenY();
final ByteBuffer pixelBuffer = BufferUtils.newByteBuffer(w * h * 4);
Gdx.gl.glBindFramebuffer(GL20.GL_FRAMEBUFFER, fbo.getFramebufferHandle());
Gdx.gl.glReadPixels(x, y, w, h, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE, pixelBuffer);
Gdx.gl.glBindFramebuffer(GL20.GL_FRAMEBUFFER, 0);
final int numBytes = w * h * 4;
byte[] imgLines = new byte[numBytes];
final int numBytesPerLine = w * 4;
for (int i = 0; i < h; i++) {
pixelBuffer.position((h - i - 1) * numBytesPerLine);
pixelBuffer.get(imgLines, i * numBytesPerLine, numBytesPerLine);
}
Pixmap pixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888);
BufferUtils.copy(imgLines, 0, pixmap.getPixels(), imgLines.length);
return pixmap;
}
示例7: GameRenderer
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public GameRenderer(Viewport viewport, Camera camera, GameEngine engine) {
this.viewport = viewport;
this.camera = camera;
this.engine = engine;
shapeRenderer = new MyShapeRenderer();
shapeRenderer.setAutoShapeType(true);
spriteBatch = new SpriteBatch();
font = new BitmapFont();
font.setColor(Color.WHITE);
font.setUseIntegerPositions(false);
font.getData().setScale(0.01f);
shadowBatch = new ModelBatch(new DepthShaderProvider());
ShaderProgram.pedantic = false;
final String vertUber = Gdx.files.internal("shaders/uber.vert").readString();
final String fragUber = Gdx.files.internal("shaders/uber.frag").readString();
modelBatch = new ModelBatch(new DefaultShaderProvider(vertUber, fragUber) {
@Override
protected Shader createShader(final Renderable renderable) {
return new UberShader(renderable, config);
}
});
}
示例8: KyperBoxGame
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public KyperBoxGame(String prefs, String game_name, Viewport view) {
this.view = view;
this.prefs_name = prefs;
if (game_name == null)
this.game_name = this.getClass().getSimpleName();
else
this.game_name = game_name;
if (prefs_name == null)
prefs_name = this.game_name + "_data";
//WARNING ===========
}
示例9: project
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public Vector2 project(Vector2 coords) {
Viewport view = layer.getState().getGame().getView();
view.project(coords);
coords.scl(getZoom());
coords.set(coords.x + position.x, coords.y + position.y);
return coords;
}
示例10: GameScreenInputAdapter
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public GameScreenInputAdapter(Game game, Viewport viewport, Hud hud) {
this.game = game;
this.viewport = viewport;
this.hud = hud;
playerDragging = false;
numTouches = 0;
allowButtonClick = false;
Gdx.input.setCatchBackKey(true);
}
示例11: OverworldController
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public OverworldController(MultiRenderer renderer, Environment environment, Viewport viewport) {
this.events = new EventHelper(this);
this.camera = new OverworldCamera(this);
this.collision = new CollisionHandler(camera, true);
this.transitions = new Pair<>();
this.environment = environment;
this.playTransitions = true;
this.renderer = renderer;
this.character = null;
this.room = null;
this.setViewport(viewport);
}
示例12: MenuHud
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public MenuHud(Viewport viewport, SpriteBatch batch, final Application app, Sprite bg, final TextureAtlas atlas)
{
super(viewport, batch);
redBG = new Sprite(app.assets.get("images/paddlandball/bg-red.png", Texture.class));
orangeBG = new Sprite(app.assets.get("images/paddlandball/bg-orange.png", Texture.class));
blueBG = new Sprite(app.assets.get("images/paddlandball/bg-blue.png", Texture.class));
greenBG = new Sprite(app.assets.get("images/paddlandball/bg-green.png", Texture.class));
colorOverlay = new ColorOverlay(bg, redBG, orangeBG, blueBG, greenBG, app, atlas);
titleLabel = new TitleLabel();
playButton = new PlayButton(app, atlas);
helpButton = new HelpButton(app, this, atlas);
titleLabel.getLabel().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 + 500, Align.center);
playButton.getButton().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 + 100, Align.center);
helpButton.getButton().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 - 100, Align.center);
colorOverlay.getImage().setPosition(Constants.V_WIDTH / 2, -150, Align.bottom);
actors.add(titleLabel.getLabel());
actors.add(playButton.getButton());
actors.add(helpButton.getButton());
actors.add(colorOverlay.getImage());
// ADD COLOR BUTTONS OF COLOR OVERLAY TO ACTOR LIST
for (ColorButton colorButton : colorOverlay.getColorButtons())
{
actors.add(colorButton.getButton());
}
addAllActorsToStage();
}
示例13: create
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的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();
}
示例14: Splash
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
public Splash(LoadReady loadReadyHandler, Viewport viewport, Batch batch) {
super("splash", viewport, batch);
this.loadReadyHandler = loadReadyHandler;
Texture backgroundTexture = new Texture("splash-back.jpg");
CB.backgroundImage = new Image(backgroundTexture);
CB.backgroundImage.setWidth(Gdx.graphics.getWidth());
CB.backgroundImage.setHeight(Gdx.graphics.getHeight());
this.addActor(CB.backgroundImage);
InitialView();
}
示例15: update
import com.badlogic.gdx.utils.viewport.Viewport; //导入依赖的package包/类
@Override
public void update(final Box2DService box2d, final Viewport viewport, final float gameX, final float gameY) {
viewport.project(entityPosition.set(gameX, gameY));
if (moving) {
updateMovementWithAngle(MathUtils.atan2(y - entityPosition.y, x - entityPosition.x));
}
}