List of usage examples for com.badlogic.gdx Gdx graphics
Graphics graphics
To view the source code for com.badlogic.gdx Gdx graphics.
Click Source Link
From source file:Tabox2D.java
License:Open Source License
private Tabox2D(Vector2 gravity) { width = Gdx.graphics.getWidth(); height = Gdx.graphics.getHeight();//from www. j a v a 2 s . c om meterSize = 100;// 1 metter = 100px, default. polyInfo = new HashMap<String, Float>(); rawForces = false; // Sides by polygon: polyInfo.put("triangle", 3f); polyInfo.put("square", 4f); polyInfo.put("pentagon", 5f); polyInfo.put("hexagon", 6f); polyInfo.put("heptagon", 7f); polyInfo.put("octagon", 8f); // Angle of the sides: polyInfo.put("triangle_angle", 120f); polyInfo.put("square_angle", 90f); polyInfo.put("pentagon_angle", 72f); polyInfo.put("hexagon_angle", 60f); polyInfo.put("heptagon_angle", 51.428f); polyInfo.put("octagon_angle", 45f); filterMin = "linear"; filterMag = "linear"; renderer = new Box2DDebugRenderer(); sr = new ShapeRenderer(); spriteBath = new SpriteBatch(); adjustCamera(); tabodies = new ArrayList<Tabody>(); world = new World(new Vector2(gravity.x, gravity.y), true); sr = new ShapeRenderer(); }
From source file:Tabox2D.java
License:Open Source License
/** * Updates simulation, default delta = Gdx.graphics.getDeltaTime() */ public void update() { this.update(Gdx.graphics.getDeltaTime()); }
From source file:MyGdxGame.java
License:Apache License
@Override public void render() { // clear the screen Gdx.gl.glClearColor(0.7f, 0.7f, 1.0f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // get the delta time float deltaTime = Gdx.graphics.getDeltaTime(); // update the koala (process input, collision detection, position update) updateKoala(deltaTime);/*www . j a v a 2 s . c om*/ // let the camera follow the koala, x-axis only camera.position.x = koala.position.x; camera.update(); // set the tile map rendere view based on what the // camera sees and render the map renderer.setView(camera); renderer.render(); // render the koala renderKoala(deltaTime); }
From source file:MyGdxGame.java
License:Apache License
private boolean isTouched(float startX, float endX) { // check if any finge is touch the area between startX and endX // startX/endX are given between 0 (left edge of the screen) and 1 (right edge of the screen) for (int i = 0; i < 2; i++) { float x = Gdx.input.getX(i) / (float) Gdx.graphics.getWidth(); if (Gdx.input.isTouched(i) && (x >= startX && x <= endX)) { return true; }//from ww w . jav a2 s. com } return false; }
From source file:OrbitingCameraController.java
License:Open Source License
/** * @return false, for further input handling * *//*from w ww. j av a2 s . co m*/ @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { touchStartX = screenX; touchStartY = Gdx.graphics.getHeight() - screenY; lastTouchX = touchStartX; lastTouchY = touchStartY; return false; }
From source file:OrbitingCameraController.java
License:Open Source License
/** * @return false, for further input handling * *///www . j av a 2s .c om @Override public boolean touchDragged(int screenX, int screenY, int pointer) { if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) { if (allowPitchMovement) pitch += (lastTouchY - (Gdx.graphics.getHeight() - screenY)) / 10; } else if (Gdx.input.isButtonPressed(Input.Buttons.MIDDLE)) { float dx = lastTouchX - screenX; float dy = lastTouchY - (Gdx.graphics.getHeight() - screenY); tempV3.set(camera.direction).crs(0, 1, 0).nor().scl(dx / 60f).scl(orbitRadius * .02f); pivotPoint.x += tempV3.x; pivotPoint.z += tempV3.z; tempV3.set(camera.direction).nor().scl(dy / 20f).scl(orbitRadius * .02f); pivotPoint.x += tempV3.x; pivotPoint.z += tempV3.z; } else if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) { if (allowYawMovement) yaw += (lastTouchX - screenX) / 5f; } lastTouchX = screenX; lastTouchY = Gdx.graphics.getHeight() - screenY; return false; }
From source file:ac.uk.dmu.ash.game.screen.CreditsScreen.java
License:Open Source License
@Override public void render(float delta) { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); fpsLabel.setText("fps: " + Gdx.graphics.getFramesPerSecond()); spriteBatch.begin();//from w w w .ja v a 2 s . co m drawTextureCentre(assets, spriteBatch, "background", 0, 0); spriteBatch.end(); stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); // Table.drawDebug(stage); // adds coloured outline to cells within the tables that are in the stage }
From source file:actors.BasicSkel.java
public void draw(Batch batch, float parentAlpha) { fireEffect.update(Gdx.graphics.getDeltaTime()); fireEffect.draw(batch);// w w w . j av a 2s .c o m iceEffect.update(Gdx.graphics.getDeltaTime()); iceEffect.draw(batch); poisonEffect.update(Gdx.graphics.getDeltaTime()); poisonEffect.draw(batch); sprite.setColor(this.getColor()); batch.setColor(this.getColor()); sprite.draw(batch); emptyHealthBar.draw(batch); if (health < 99999) fullHealthBar.draw(batch); }
From source file:application.concretion.GameScreenController.java
License:Open Source License
@Override public void render() { // log.log(); // Clean the screen Gdx.gl.glClearColor(1, 1, 1, 1);/*from w w w . j ava 2 s. c o m*/ Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT | GL10.GL_STENCIL_BUFFER_BIT); // Update and draw the screen currentScreen.update(Gdx.graphics.getDeltaTime()); currentScreen.draw(Gdx.graphics.getDeltaTime()); // Check if the current screen is done and set the next screen if return // null means that is not done nextScreen = currentScreen.nextScreen(); if (nextScreen != null) { // Dispose the resources of the current screen currentScreen.dispose(); // Set the next screen currentScreen = nextScreen; } }
From source file:at.hid.tabletopsimulator.screens.About.java
License:Apache License
@Override public void show() { TableTopSimulator.debug(this.getClass().toString(), "creating About screen"); stage = new Stage(new ExtendViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); Gdx.input.setInputProcessor(stage);/*from ww w. jav a 2s .co m*/ // creating skin TableTopSimulator.debug(this.getClass().toString(), "creating skin"); skin = TableTopSimulator.assets.get("ui/gui.json", Skin.class); table = new Table(skin); // table.setFillParent(true); // table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // creating heading TableTopSimulator.debug(this.getClass().toString(), "creating heading"); Label lblHeading = new Label(TableTopSimulator.getLangBundle().format("About.lblHeading.text"), skin); final Label lblContent = new Label("http://libgdx.badlogicgames.com/\r\n" + "\r\n" + "libGDX is licensed under the Apache 2 License,\r\n" + "meaning you can use it free of charge, without strings attached in commercial and non-commercial projects.\r\n" + "We love to get (non-mandatory) credit in case you release a game or app using libgdx!", skin, "content"); // creating list final List<String> listAbout = new List<String>(skin, "content"); ArrayList<String> newItems = new ArrayList<String>(); newItems.add("libgdx"); newItems.add("libgdx-utils"); newItems.add("flare gameart"); String[] data = new String[newItems.size()]; listAbout.setItems(newItems.toArray(data)); listAbout.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (listAbout.getSelected().equals("libgdx")) { lblContent.clear(); lblContent.setText("http://libgdx.badlogicgames.com/\r\n" + "\r\n" + "libGDX is licensed under the Apache 2 License,\r\n" + "meaning you can use it free of charge, without strings attached in commercial and non-commercial projects.\r\n" + "We love to get (non-mandatory) credit in case you release a game or app using libgdx!"); } else if (listAbout.getSelected().equals("libgdx-utils")) { lblContent.clear(); lblContent.setText("https://bitbucket.org/dermetfan/libgdx-utils/wiki/Home\r\n" + "\r\n" + "/* Copyright (c) 2014 PixelScientists\r\n" + "*\r\n" + "* The MIT License (MIT)\r\n" + "*\r\n" + "* Permission is hereby granted, free of charge, to any person obtaining a copy of\r\n" + "* this software and associated documentation files (the \"Software\"), to deal in\r\n" + "* the Software without restriction, including without limitation the rights to\r\n" + "* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r\n" + "* the Software, and to permit persons to whom the Software is furnished to do so,\r\n" + "* subject to the following conditions:\r\n" + "*\r\n" + "* The above copyright notice and this permission notice shall be included in all\r\n" + "* copies or substantial portions of the Software.\r\n" + "*\r\n" + "* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n" + "* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r\n" + "* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r\n" + "* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r\n" + "* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r\n" + "* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n" + "*/"); } else if (listAbout.getSelected().equals("flare gameart")) { lblContent.clear(); lblContent.setText("https://github.com/clintbellanger/flare-game\r\n" + "\r\n" + "Flare (the game) is Copyright 2010-2013 Clint Bellanger. Contributors retain copyrights to their original contributions.\r\n" + "\r\n" + "The Flare Engine is released under GPL version 3 or later.\r\n" + "\r\n" + "All of Flare's art and data files are released under CC-BY-SA 3.0. Later versions are permitted.\r\n" + "\r\n" + "The Liberation Sans fonts version 2 are released under the SIL Open Font License, Version 1.1.\r\n" + "\r\n" + "The GNU Unifont font is released under GPL v2, with the exception that embedding the font in a document does not in itself bind that document to the terms of the GPL."); } } }); // creating buttons TableTopSimulator.debug(this.getClass().toString(), "creating buttons"); TextButton btnBack = new TextButton(TableTopSimulator.getLangBundle().format("About.btnBack.text"), skin); btnBack.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { TableTopSimulator.debug(this.getClass().toString(), "switching to Options screen"); ((Game) Gdx.app.getApplicationListener()).setScreen(new Options()); dispose(); } }); btnBack.pad(10); ScrollPane spAboutList = new ScrollPane(null, skin); ScrollPane spAboutContent = new ScrollPane(null, skin); SplitPane splitAbout = new SplitPane(spAboutList, spAboutContent, false, skin); splitAbout.setSplitAmount(0.2f); spAboutList.setWidget(listAbout); spAboutContent.setWidget(lblContent); // building ui TableTopSimulator.debug(this.getClass().toString(), "building ui"); table.add(lblHeading).spaceBottom(100).row(); table.add(splitAbout).spaceBottom(15).width(1200).row(); table.add(btnBack).spaceBottom(15).row(); if (TableTopSimulator.DEBUG) { table.debug(); // draw debug lines splitAbout.debug(); // draw debug lines } stage.addActor(table); }