com.badlogic.gdx.graphics.g2d.SpriteBatch Java Examples
The following examples show how to use
com.badlogic.gdx.graphics.g2d.SpriteBatch.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NavMeshDebugDrawer.java From GdxDemo3D with Apache License 2.0 | 6 votes |
private void drawNavMeshIndices(SpriteBatch spriteBatch, Camera camera, BitmapFont font) { // TODO: Get rid of all the transform matrix setting if (spriteBatch.isDrawing()) { spriteBatch.end(); } spriteBatch.begin(); spriteBatch.setProjectionMatrix(camera.combined); for (int i = 0; i < navMesh.graph.getNodeCount(); i++) { Triangle t = navMesh.graph.getTriangleFromGraphIndex(i); if (triangleIsVisible(t)) { tmpMatrix.set(camera.view).inv().getRotation(tmpQuat); tmpMatrix.setToTranslation(t.centroid).rotate(tmpQuat); spriteBatch.setTransformMatrix(tmpMatrix); font.draw(spriteBatch, Integer.toString(t.triIndex), 0, 0); } } spriteBatch.end(); }
Example #2
Source File: GigaGalHud.java From ud406 with MIT License | 6 votes |
public void render(SpriteBatch batch, int lives, int ammo, int score) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); final String hudString = Constants.HUD_SCORE_LABEL + score + "\n" + Constants.HUD_AMMO_LABEL + ammo; font.draw(batch, hudString, Constants.HUD_MARGIN, viewport.getWorldHeight() - Constants.HUD_MARGIN); final TextureRegion standingRight = Assets.instance.gigaGalAssets.standingRight; for (int i = 1; i <= lives; i++) { final Vector2 drawPosition = new Vector2( viewport.getWorldWidth() - i * (Constants.HUD_MARGIN / 2 + standingRight.getRegionWidth()), viewport.getWorldHeight() - Constants.HUD_MARGIN - standingRight.getRegionHeight() ); Utils.drawTextureRegion( batch, standingRight, drawPosition ); } batch.end(); }
Example #3
Source File: IciclesScreen.java From ud405 with MIT License | 6 votes |
@Override public void show() { iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE); renderer = new ShapeRenderer(); renderer.setAutoShapeType(true); hudViewport = new ScreenViewport(); batch = new SpriteBatch(); font = new BitmapFont(); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); player = new Player(iciclesViewport); icicles = new Icicles(iciclesViewport, difficulty); Gdx.input.setInputProcessor(this); topScore = 0; }
Example #4
Source File: WrathCardIconPatch.java From jorbs-spire-mod with MIT License | 6 votes |
@SpirePostfixPatch public static void Postfix(SingleCardViewPopup __this, SpriteBatch sb) { AbstractCard card = ReflectionUtils.getPrivateField(__this, SingleCardViewPopup.class, "card"); int wrathCount = WrathField.wrathEffectCount.get(card); if (wrathCount == 0 || card.isLocked || !card.isSeen) { return; } RenderUtils.renderAtlasRegionCenteredAt(sb, wrathIconOverlayImg, WRATH_ICON_OFFSET_X, WRATH_ICON_OFFSET_Y); String text = Integer.toString(wrathCount); BitmapFont font = FontHelper.SCP_cardEnergyFont; float x = WRATH_TEXT_OFFSET_X; if (wrathCount > 9) x -= (20 * Settings.scale); FontHelper.renderFont(sb, font, text, x, WRATH_TEXT_OFFSET_Y, WRATH_TEXT_COLOR); }
Example #5
Source File: BGDrawer.java From libGDX-Path-Editor with Apache License 2.0 | 6 votes |
public void presentOverlayBG(int scrW, int scrH, int camX, int camY, int camW, int camH, SpriteBatch batch) { batch.begin(); t.setSize(camW, (int)(camY + camH/2 - scrH)); t.setPosition((int)(camX - camW/2), scrH); t.draw(batch, overlayBGAlpha); b.setSize(camW, (int)(-camY + camH/2)); b.setPosition((int)(camX - camW/2), (int)(camY - camH/2)); b.draw(batch, overlayBGAlpha); l.setSize((int)(-camX + camW/2), scrH); l.setPosition((int)(camX - camW/2), 0); l.draw(batch, overlayBGAlpha); r.setSize((int)(camX + camW/2 - scrW), scrH); r.setPosition(scrW, 0); r.draw(batch, overlayBGAlpha); batch.end(); }
Example #6
Source File: CraftingScreen.java From TerraLegion with MIT License | 6 votes |
@Override public void render(SpriteBatch sb) { sb.setProjectionMatrix(camera.combined); sb.begin(); sb.draw(bg, 0, 0); itemNameLabel.render(sb); itemInfoLabel.render(sb); cancelBtn.render(sb); craftingBtn.render(sb); invBtn.render(sb); if (selectedRecipe != null) craftBtn.render(sb); sb.end(); stage.draw(); }
Example #7
Source File: Utils.java From ud406 with MIT License | 6 votes |
public static void drawTextureRegion(SpriteBatch batch, TextureRegion region, float x, float y) { batch.draw( region.getTexture(), x, y, 0, 0, region.getRegionWidth(), region.getRegionHeight(), 1, 1, 0, region.getRegionX(), region.getRegionY(), region.getRegionWidth(), region.getRegionHeight(), false, false); }
Example #8
Source File: AtlasRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
@Override public void draw(SpriteBatch batch, float x, float y, float scaleX, float scaleY, float rotation, Color tint) { float dx = getAlignDx(getWidth(), orgAlign); float dy = getAlignDy(getHeight(), orgAlign); if (tex == null) { RectangleRenderer.draw(batch, x + dx * scaleX, y + dy * scaleY, getWidth() * scaleX, getHeight() * scaleY, Color.RED); return; } x = x + tex.offsetX + dx; y = y + tex.offsetY + dy; if (tint != null) batch.setColor(tint); batch.draw(tex, x, y, -dx - tex.offsetX, -dy - tex.offsetY, tex.packedWidth, tex.packedHeight, flipX ? -scaleX : scaleX, scaleY, rotation); if (tint != null) batch.setColor(Color.WHITE); }
Example #9
Source File: HelpScreen.java From FruitCatcher with Apache License 2.0 | 6 votes |
@Override public void show() { imageProvider = game.getImageProvider(); backgroundImage = imageProvider.getBackgroundSpring(); buttons = new Button [1]; buttons[0] = new Button(imageProvider.getBack()); camera = new OrthographicCamera(); camera.setToOrtho(false, imageProvider.getScreenWidth(), imageProvider.getScreenHeight()); batch = new SpriteBatch(); buttons[0].setPos(10, 10); font = new BitmapFont(Gdx.files.internal("fonts/poetsen.fnt"), Gdx.files.internal("fonts/poetsen.png"), false); startLine = 0; lineHeight = 30; lastLineIndex = game.getTextResources().getHelpLines().length - 1; Gdx.input.setInputProcessor(this); Gdx.input.setCatchBackKey(true); }
Example #10
Source File: MainMenu.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
public MainMenu (Invaders invaders) { super(invaders); spriteBatch = new SpriteBatch(); background = new Texture(Gdx.files.internal("data/planet.jpg")); background.setFilter(TextureFilter.Linear, TextureFilter.Linear); logo = new Texture(Gdx.files.internal("data/title.png")); logo.setFilter(TextureFilter.Linear, TextureFilter.Linear); font = new BitmapFont(Gdx.files.internal("data/font16.fnt"), Gdx.files.internal("data/font16.png"), false); if (invaders.getController() != null) { invaders.getController().addListener(new ControllerAdapter() { @Override public boolean buttonUp(Controller controller, int buttonIndex) { controller.removeListener(this); isDone = true; return false; } }); } }
Example #11
Source File: BatchManager.java From shapedrawer with MIT License | 5 votes |
public TextureRegion setTextureRegion(TextureRegion region) { TextureRegion oldRegion = this.r; this.r = region; float u = 0.5f * (r.getU() + r.getU2()); float v = 0.5f * (r.getV() + r.getV2()); for (int i = 0; i < verts.length; i+=VERTEX_SIZE) { verts[i + SpriteBatch.U1] = u; verts[i + SpriteBatch.V1] = v; } return oldRegion; }
Example #12
Source File: Particle.java From Unlucky with MIT License | 5 votes |
public void render(SpriteBatch batch) { if (shouldRemove) { if (deathAnim != null) batch.draw(deathAnim.getKeyFrame(false), position.x, position.y); } else { if (animated && anim != null) batch.draw(anim.getKeyFrame(true), position.x, position.y); else { if (sprite != null) batch.draw(sprite, position.x, position.y); } } }
Example #13
Source File: SlideUpAnimation.java From Radix with MIT License | 5 votes |
@Override public void init() { super.init(); fbo = new FrameBuffer(Pixmap.Format.RGBA4444, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); fboTex = fbo.getColorBufferTexture(); Gdx.gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Gdx.gl.glEnable(GL_BLEND); SpriteBatch batch = new SpriteBatch(); batch.setProjectionMatrix(RadixClient.getInstance().getHudCamera().combined); fbo.bind(); batch.begin(); currentScreen.render(false, batch); batch.end(); FrameBuffer.unbind(); }
Example #14
Source File: BubbleLevelScreen.java From ud405 with MIT License | 5 votes |
@Override public void show() { axisViewport = new FitViewport(WORLD_SIZE, WORLD_SIZE); renderer = new ShapeRenderer(); renderer.setAutoShapeType(true); batch = new SpriteBatch(); textViewport = new ScreenViewport(); font = new BitmapFont(); font.getData().setScale(TEXT_SCALE); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); maxAcceleration = 0; minAcceleration = Float.MAX_VALUE; }
Example #15
Source File: SettingsScreen.java From Unlucky with MIT License | 5 votes |
@Override public void render(float dt) { update(dt); if (!inGame) { for (int i = 0; i < game.menuBackground.length; i++) { game.menuBackground[i].update(dt); } } // clear screen Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if (renderBatch) { stage.getBatch().setProjectionMatrix(stage.getCamera().combined); stage.getBatch().begin(); // fix fading if (batchFade) stage.getBatch().setColor(Color.WHITE); // if in game the background is the background of the current world if (inGame) { stage.getBatch().draw(rm.worldSelectBackgrounds[worldIndex], 0, 0); } else { for (int i = 0; i < game.menuBackground.length; i++) { game.menuBackground[i].render((SpriteBatch) stage.getBatch()); } } stage.getBatch().end(); } stage.act(dt); stage.draw(); }
Example #16
Source File: Level.java From ud406 with MIT License | 5 votes |
public void render(SpriteBatch batch) { batch.begin(); for (Platform platform : platforms) { platform.render(batch); } gigaGal.render(batch); batch.end(); }
Example #17
Source File: UI.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
public UI(World w) { this.w = w; recorder = new Recorder(w); testerBot = new TesterBot(w); batch = new SpriteBatch(); screens = new BladeScreen[Screens.values().length]; Gdx.input.setCatchKey(Input.Keys.MENU, true); Gdx.input.setCatchKey(Input.Keys.BACK, true); loadAssets(); screens[Screens.INIT_SCREEN.ordinal()] = getCustomScreenInstance(Screens.INIT_SCREEN.toString(), InitScreen.class); screens[Screens.SCENE_SCREEN.ordinal()] = getCustomScreenInstance(Screens.SCENE_SCREEN.toString(), DefaultSceneScreen.class); screens[Screens.LOADING_SCREEN.ordinal()] = getCustomScreenInstance(Screens.LOADING_SCREEN.toString(), LoadingScreen.class); screens[Screens.MENU_SCREEN.ordinal()] = getCustomScreenInstance(Screens.MENU_SCREEN.toString(), MenuScreen.class); screens[Screens.HELP_SCREEN.ordinal()] = getCustomScreenInstance(Screens.HELP_SCREEN.toString(), HelpScreen.class); screens[Screens.CREDIT_SCREEN.ordinal()] = getCustomScreenInstance(Screens.CREDIT_SCREEN.toString(), CreditsScreen.class); screens[Screens.LOAD_GAME_SCREEN.ordinal()] = getCustomScreenInstance(Screens.LOAD_GAME_SCREEN.toString(), LoadSaveScreen.class); screens[Screens.SAVE_GAME_SCREEN.ordinal()] = getCustomScreenInstance(Screens.SAVE_GAME_SCREEN.toString(), LoadSaveScreen.class); for (BladeScreen s : screens) s.setUI(this); setCurrentScreen(Screens.INIT_SCREEN); }
Example #18
Source File: SuperJumper.java From ashley-superjumper with Apache License 2.0 | 5 votes |
@Override public void create () { batcher = new SpriteBatch(); Settings.load(); Assets.load(); setScreen(new MainMenuScreen(this)); }
Example #19
Source File: GameplayScreen.java From ud406 with MIT License | 5 votes |
@Override public void show() { AssetManager am = new AssetManager(); Assets.instance.init(am); batch = new SpriteBatch(); gameplayViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE); level = new Level(gameplayViewport); chaseCam = new ChaseCam(gameplayViewport.getCamera(), level.getGigaGal()); }
Example #20
Source File: LobbyScreen.java From killingspree with MIT License | 5 votes |
@Override public void show() { font = game.getFont(120); batch = new SpriteBatch(); camera = new OrthographicCamera(); viewport = new FitViewport(1280, 720, camera); camera.setToOrtho(false, 1280, 720); buttons = new ArrayList<MyButton>(); isServer = false; ipAddresses = new ArrayList<String>(); markForDispose = false; startGame = false; host = "127.0.0.1"; }
Example #21
Source File: Program.java From INFDEV02-4 with MIT License | 5 votes |
@Override public void create() { this.batch = new SpriteBatch(); this.backgroundImage = new Texture("coffee.jpg"); GUIConstructor guiConstructor = new GUIConstructor(); this.guiManager = guiConstructor.instantiate("1", () -> { Gdx.app.exit(); }); this.inputManager = new GDXMouse(); this.drawingManager = new GDXDrawingAdapter(this.batch); this.drawVisitor = new DefaultDrawVisitor(this.drawingManager); this.updateVisitor = new DefaultUpdateVisitor(this.inputManager); }
Example #22
Source File: InventoryUI.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float alpha) { Inventory inventory = sceneScreen.getWorld().getInventory(); if (!inventory.isVisible()) { setVisible(false); return; } if (style.background != null) { style.background.draw(batch, getX(), getY(), getWidth(), getHeight()); } // DRAW ITEMS int capacity = cols * rows; for (int i = 0; i < inventory.getNumItems() && i < capacity; i++) { SpriteActor a = inventory.get(i); ActorRenderer r = a.getRenderer(); float size = (tileSize - rowSpace) / (r.getHeight() > r.getWidth() ? r.getHeight() : r.getWidth()); float x = i % cols; float y = (rows - 1) - i / cols; if (style.itemBackground != null) { style.itemBackground.draw(batch, getX() + x * tileSize + x * rowSpace + margin, getY() + y * tileSize + y * rowSpace + margin, tileSize, tileSize); } r.draw((SpriteBatch) batch, getX() + x * tileSize + x * rowSpace + tileSize / 2 + margin, getY() + (tileSize - r.getHeight() * size) / 2 + y * tileSize + y * rowSpace + margin, size, size, 0f, a.getTint()); } super.draw(batch, alpha); }
Example #23
Source File: SpriteBatchUtils.java From uracer-kotd with Apache License 2.0 | 5 votes |
public static void drawString (SpriteBatch batch, String string, float x, float y) { String upstring = string.toUpperCase(); for (int i = 0; i < string.length(); i++) { char ch = upstring.charAt(i); for (int ys = 0; ys < chars.length; ys++) { int xs = chars[ys].indexOf(ch); if (xs >= 0) { draw(batch, debugFont[xs][ys], x + i * debugFontW, y); } } } }
Example #24
Source File: AccelerometerAxesScreen.java From ud405 with MIT License | 5 votes |
@Override public void show() { axisViewport = new FitViewport(WORLD_SIZE, WORLD_SIZE); renderer = new ShapeRenderer(); renderer.setAutoShapeType(true); batch = new SpriteBatch(); textViewport = new ScreenViewport(); font = new BitmapFont(); font.getData().setScale(TEXT_SCALE); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); maxAcceleration = 0; minAcceleration = Float.MAX_VALUE; }
Example #25
Source File: GameBatchRenderer.java From uracer-kotd with Apache License 2.0 | 5 votes |
public GameBatchRenderer (GL20 gl) { // setup a top-left origin // y-flip topLeftOrigin = new Matrix4(); topLeftOrigin.setToOrtho(0, ScaleUtils.PlayWidth, ScaleUtils.PlayHeight, 0, 0, 10); identity = new Matrix4(); // Issues may arise on Tegra2 (Asus Transformer) devices if the buffers' // count is higher than 10 // batch = new SpriteBatch(1000, 8); batch = new SpriteBatch(); begin = false; this.gl = gl; }
Example #26
Source File: CampfireThirstEffect.java From jorbs-spire-mod with MIT License | 5 votes |
public void render(SpriteBatch sb) { sb.setColor(this.screenColor); sb.draw(ImageMaster.WHITE_SQUARE_IMG, 0.0F, 0.0F, (float) Settings.WIDTH, (float)Settings.HEIGHT); if (AbstractDungeon.screen == AbstractDungeon.CurrentScreen.GRID) { AbstractDungeon.gridSelectScreen.render(sb); } }
Example #27
Source File: GameplayScreen.java From ud406 with MIT License | 5 votes |
@Override public void show() { AssetManager am = new AssetManager(); Assets.instance.init(am); batch = new SpriteBatch(); gameplayViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE); level = new Level(gameplayViewport); chaseCam = new ChaseCam(gameplayViewport.getCamera(), level.getGigaGal()); }
Example #28
Source File: Level.java From ud406 with MIT License | 5 votes |
public void render(SpriteBatch batch, ShapeRenderer renderer) { renderer.begin(ShapeType.Filled); // TODO: Render all platforms in the platform array for (Platform platform : platforms) { platform.render(renderer); } renderer.end(); batch.begin(); gigaGal.render(batch); batch.end(); }
Example #29
Source File: Filtering.java From ud406 with MIT License | 5 votes |
@Override public void create() { batch = new SpriteBatch(); viewport = new ScreenViewport(); nearest = new Texture("standing-right.png"); linear = new Texture("standing-right.png"); linear.setFilter(TextureFilter.Linear, TextureFilter.Linear); }
Example #30
Source File: DeltaScreen.java From ud405 with MIT License | 5 votes |
@Override public void show() { Gdx.app.log(TAG, "show() called"); batch = new SpriteBatch(); font = new BitmapFont(); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); font.getData().setScale(FONT_SCALE); }