com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch Java Examples
The following examples show how to use
com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch.
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: SpriteAnimationDrawable.java From talos with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float x, float y, float width, float height, float rotation) { if(batch instanceof PolygonSpriteBatch) { PolygonSpriteBatch polygonSpriteBatch = (PolygonSpriteBatch) batch; Frame frame = animation.getKeyFrame(phase, false); updateVertices(x-width/2f, y-height/2f, width, height, batch.getColor(), frame.u1, frame.v1, frame.u2, frame.v2, rotation); polygonSpriteBatch.draw(region.getTexture(), vertices, 0, vertices.length, indexes, 0, indexes.length); } }
Example #2
Source File: TalosDemo.java From talos with Apache License 2.0 | 5 votes |
@Override public void create() { /** * We need a viewport for proper camerawork */ viewport = new FitViewport(10f, 10f); viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); /** * We may need polygon sprite batch to render more complex VFX such us beams */ batch = new PolygonSpriteBatch(); /** * Prepare the texture atlas. * Normally just load Texture Atlas, but for the sake of demo this will be creating fake atlas from just one texture. */ TextureRegion textureRegion = new TextureRegion(new Texture(Gdx.files.internal("fire.png"))); TextureAtlas textureAtlas = new TextureAtlas(); textureAtlas.addRegion("fire", textureRegion); /** * Creating particle effect instance from particle effect descriptor */ ParticleEffectDescriptor effectDescriptor = new ParticleEffectDescriptor(Gdx.files.internal("fire.p"), textureAtlas); effect = effectDescriptor.createEffectInstance(); }
Example #3
Source File: WorldRenderer.java From SIFTrain with MIT License | 5 votes |
public WorldRenderer(World world) { this.world = world; this.cam = new OrthographicCamera(CAMERA_WIDTH, CAMERA_HEIGHT); this.cam.position.set(0f, 0f, 0f); this.cam.update(); spriteBatch = new PolygonSpriteBatch(); renderer = new ShapeRenderer(); layout = new GlyphLayout(); loadTextures(); }
Example #4
Source File: GameWrapper.java From mini2Dx with Apache License 2.0 | 5 votes |
protected Graphics createGraphicsContext() { LibgdxSpriteBatchWrapper spriteBatch = new LibgdxSpriteBatchWrapper(); PolygonSpriteBatch polygonSpriteBatch = new PolygonSpriteBatch(); ShapeRenderer shapeRenderer = new ShapeRenderer(); return new LibgdxGraphics(this, spriteBatch, polygonSpriteBatch, shapeRenderer); }
Example #5
Source File: LibgdxGraphics.java From mini2Dx with Apache License 2.0 | 5 votes |
public LibgdxGraphics(GameWrapper gameWrapper, LibgdxSpriteBatchWrapper spriteBatch, PolygonSpriteBatch polygonSpriteBatch, ShapeRenderer shapeRenderer) { this.gameWrapper = gameWrapper; this.spriteBatch = spriteBatch; this.shapeRenderer = shapeRenderer; this.shapeRenderer.setAutoShapeType(true); this.polygonSpriteBatch = polygonSpriteBatch; this.windowWidth = Gdx.graphics.getWidth(); this.windowHeight = Gdx.graphics.getHeight(); defaultTint = new LibgdxReadOnlyColor(spriteBatch.getColor().cpy()); font = Mdx.fonts.defaultFont(); tint = defaultTint; lineHeight = 1; color = new LibgdxColor(1f, 1f, 1f, 1f); defaultColor = new LibgdxReadOnlyColor(1f, 1f, 1f, 1f); backgroundColor = new LibgdxColor(0f, 0f, 0f, 1f); colorTextureCache = new ShapeTextureCache(); translationX = 0; translationY = 0; scaleX = 1f; scaleY = 1f; rotation = 0f; rotationX = 0f; rotationY = 0f; /* Create Ortho camera so that 0,0 is in top-left */ camera = new OrthographicCamera(); }
Example #6
Source File: LibgdxGraphicsTest.java From mini2Dx with Apache License 2.0 | 5 votes |
@Before public void setup() { mockery = new Mockery(); mockery.setImposteriser(ClassImposteriser.INSTANCE); fonts = mockery.mock(Fonts.class); gameFont = mockery.mock(GameFont.class); gameWrapper = mockery.mock(GameWrapper.class); spriteBatch = mockery.mock(LibgdxSpriteBatchWrapper.class); polygonSpriteBatch = mockery.mock(PolygonSpriteBatch.class); shapeRenderer = mockery.mock(ShapeRenderer.class); gdxGraphics = mockery.mock(com.badlogic.gdx.Graphics.class); Mdx.fonts = fonts; Gdx.graphics = gdxGraphics; mockery.checking(new Expectations() { { one(shapeRenderer).setAutoShapeType(true); one(fonts).defaultFont(); will(returnValue(gameFont)); one(gdxGraphics).getWidth(); will(returnValue(800)); one(gdxGraphics).getHeight(); will(returnValue(600)); one(spriteBatch).getColor(); will(returnValue(new Color())); } }); graphics = new LibgdxGraphics(gameWrapper, spriteBatch, polygonSpriteBatch, shapeRenderer); }
Example #7
Source File: UIStage.java From talos with Apache License 2.0 | 4 votes |
public UIStage (Skin skin) { this.stage = new Stage(new ScreenViewport(), new PolygonSpriteBatch()); this.skin = skin; this.dragAndDrop = new DragAndDrop(); }
Example #8
Source File: WorkplaceStage.java From talos with Apache License 2.0 | 4 votes |
public WorkplaceStage() { stage = new Stage(new ScreenViewport(), new PolygonSpriteBatch()); cameraController = new CameraController(getCamera()); }