本文整理汇总了Java中com.badlogic.gdx.graphics.OrthographicCamera类的典型用法代码示例。如果您正苦于以下问题:Java OrthographicCamera类的具体用法?Java OrthographicCamera怎么用?Java OrthographicCamera使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OrthographicCamera类属于com.badlogic.gdx.graphics包,在下文中一共展示了OrthographicCamera类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的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();
}
示例2: renderName
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的package包/类
/**
* Zeigt den Namenswahl Bilschirm an
*
* @param camera die aktuelle Kamera
* @param deltaTime die vergangene Zeit seit dem letztem Frame
*/
public void renderName(OrthographicCamera camera, float deltaTime)
{
strokeTimer += deltaTime;
if (strokeTimer > 0.6f)
{
strokeTimer = 0f;
stateSwitch = !stateSwitch;
playerNameStroke = String.format("%s%s", playerName, stateSwitch ? " " : "|");
}
fontLayout.setText(font, localeBundle.get("name_eingeben"), Color.WHITE, camera.viewportWidth, Align.center, false);
font.draw(batch, fontLayout, -camera.viewportWidth / 2, camera.viewportHeight / 2 - 120);
fontLayout.setText(font, playerNameStroke, Color.ROYAL, camera.viewportWidth, Align.center, false);
font.draw(batch, fontLayout, -camera.viewportWidth / 2, 30);
fontLayout.setText(smallFont, localeBundle.get("enter_bestaetigen"), Color.WHITE, camera.viewportWidth, Align.center, false);
smallFont.draw(batch, fontLayout, -camera.viewportWidth / 2, -camera.viewportHeight / 2 + 70);
}
示例3: GameService
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的package包/类
public GameService(SpriteBatch batch, IGameAsset asset,
BaseGameSetting setting, OrthographicCamera camera,
ISceneManager sceneManager) {
this.batch = batch;
this.asset = asset;
this.setting = setting;
if (asset == null)
this.asset = new DefaultGameAsset();
if (setting == null)
this.setting = new DefaultGameSetting();
this.camera = camera;
this.setChangeScene(sceneManager);
Rectangle.tmp.set(0, 0, getWindowSize().x, getWindowSize().y);
services = new IService[MAX_SERVICES];
}
示例4: touchInRectangle
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的package包/类
public static boolean touchInRectangle(Rectangle r, OrthographicCamera camera) {
if (Gdx.input.isTouched()) {
Vector3 touchPos = new Vector3();
touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
camera.unproject(touchPos);
return r.x <= touchPos.x && r.x + r.width >= touchPos.x
&& r.y <= touchPos.y && r.y + r.height >= touchPos.y;
}
return false;
}
示例5: create
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的package包/类
@Override
public void create() {
rotationSpeed = 0.5f;
mesh = new Mesh(true, 4, 6,
new VertexAttribute(VertexAttributes.Usage.Position, 3,"attr_Position"),
new VertexAttribute(Usage.TextureCoordinates, 2, "attr_texCoords"));
texture = new Texture(Gdx.files.internal("data/Jellyfish.jpg"));
mesh.setVertices(new float[] {
-1024f, -1024f, 0, 0, 1,
1024f, -1024f, 0, 1, 1,
1024f, 1024f, 0, 1, 0,
-1024f, 1024f, 0, 0, 0
});
mesh.setIndices(new short[] { 0, 1, 2, 2, 3, 0 });
cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
xScale = Gdx.graphics.getWidth()/(float)TARGET_WIDTH;
yScale = Gdx.graphics.getHeight()/(float)TARGET_HEIGHT;
font = loadBitmapFont("default.fnt", "default.png");
scale = Math.min(xScale, yScale);
cam.zoom = 1/scale;
// cam.project(start_position);
cam.position.set(0, 0, 0);
batch = new SpriteBatch();
}
示例6: create
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的package包/类
@Override
public void create() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
camera = new OrthographicCamera(1, h/w);
batch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("data/libgdx.png"));
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
TextureRegion region = new TextureRegion(texture, 0, 0, 200, 200);
sprite = new Sprite(region);
sprite.setSize(1f, sprite.getHeight() / sprite.getWidth());
sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
sprite.setPosition(-.5f, -.5f);
}
示例7: MenuScreen
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的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);
}
示例8: LevelScreen
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的package包/类
LevelScreen(GftGame game) {
this.game = game;
this.guiCam = new OrthographicCamera(800, 480);
this.guiCam.position.set(800 / 2, 480 / 2, 0);
this.backBounds = new Rectangle(7, 432, 48, 48);
this.autoMoveToNextBounds = new Rectangle(0, 0, 800, 62);
this.levelBounds = new ArrayList<Rectangle>();
int line = 0;
int column = 0;
for(int i = 0; i < LEVELS; i++) {
this.levelBounds.add(i, new Rectangle(370 + 75 * column++, 240 - 70 * line, 57, 57));
if(column == 5) {
column = 0;
line++;
}
}
this.touchPoint = new Vector3();
}
示例9: GameCenter
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的package包/类
public GameCenter(Chat game){
this.game = game;
/*Camera Settings*/
camera = new OrthographicCamera();
camera.setToOrtho(false,480,800);
camera.position.set(480/2,800/2,0);
/*Button Areas*/
wordTiles = new Rectangle(480/2-250/2,800/2,250,55);
Arkanoid = new Rectangle(480/2-250/2,800/2-60,250,55);
WordCrush = new Rectangle(480/2-250/2,800/2-120,250,55);
EndlessRoad = new Rectangle(480/2-250/2,800/2-180,250,55);
bottone4 = new Rectangle(480/2-250/2,800/2-240,250,55);
buttonTexture = new Texture("green_button00.png");
touch = new Vector3();
}
示例10: ScreenCombat
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的package包/类
public ScreenCombat(GameManager gameManager) {
this.gameManager = gameManager;
managerAssets = ManagerAssets.getInstance();
cam = new OrthographicCamera();
UpdateDisplayCombat.getInstance().setScreenCombat(this);
camera = new PerspectiveCamera(40, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.position.set(0, 0, 350);//initial 180
camera.lookAt(0, 0, 0);
camera.far = 2500;
camera.near = 1;
camera.update();
centerPlayer = new Integer[7];
for(int i=0;i<7;i++){
centerPlayer[i]=-1;
}
}
示例11: initUtils
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的package包/类
private void initUtils() {
//init camera & viewport
camera = new OrthographicCamera();
viewport = new StretchViewport(Polymorph.WORLD_WIDTH, Polymorph.WORLD_HEIGHT, camera);
viewport.apply(true);
camera.update();
//init sprite batch
batch = new SpriteBatch();
batch.setProjectionMatrix(camera.combined);
//init font
FreeTypeFontGenerator fontGenerator = polymorph.getAssetManager().get(Polymorph.FONT_BOLD_PATH, FreeTypeFontGenerator.class);
FreeTypeFontParameter fontSettings = new FreeTypeFontParameter();
fontSettings.size = 80;
fontSettings.minFilter = TextureFilter.Linear;
fontSettings.magFilter = TextureFilter.Linear;
font = fontGenerator.generateFont(fontSettings);
}
示例12: show
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的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;
}
示例13: show
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的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));
}
示例14: render
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的package包/类
public void render(OrthographicCamera camera, SpriteBatch batch, int y, MenuEntry activeEntry, SchoolGame game, I18NBundle localeBundle, float deltaTime) {
Color entryColor = getColor();
if (this == activeEntry)
{
entryColor = getActiveColor();
}
if (!isEnabled())
{
entryColor = getDisabledColor();
}
if (font == null)
font = game.getDefaultFont();
if (fontSmall == null)
fontSmall = game.getLongTextFont();
fontLayout.setText(font, localeBundle.format(getLabel(), id, used, playerName, gender), entryColor, camera.viewportWidth, Align.center, false);
font.draw(batch, fontLayout, -camera.viewportWidth / 2, y);
fontLayout.setText(fontSmall, localeBundle.format(detail, used, levelName, playTime), entryColor, camera.viewportWidth, Align.center, false);
fontSmall.draw(batch, fontLayout, -camera.viewportWidth / 2, y - 50);
}
示例15: RenderSystem
import com.badlogic.gdx.graphics.OrthographicCamera; //导入依赖的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);
}