Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mygdx.game;
- import com.badlogic.gdx.ApplicationAdapter;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.graphics.GL20;
- import com.badlogic.gdx.graphics.Pixmap;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch;
- import com.badlogic.gdx.graphics.g2d.TextureRegion;
- import com.badlogic.gdx.scenes.scene2d.ui.Skin;
- import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
- import space.earlygrey.shapedrawer.ShapeDrawer;
- import space.earlygrey.shapedrawer.scene2d.ShapeDrawerDrawable;
- public class MyGdxGame extends ApplicationAdapter {
- private Skin skin;
- private Texture tmpTex;
- private PolygonSpriteBatch batch;
- private ShapeDrawer shape;
- private float angle;
- @Override
- public void create () {
- /* Setting up the Stage. */
- skin = new Skin(Gdx.files.internal("skin.json"));
- batch = new PolygonSpriteBatch();
- /* Ideally, you would extract such a pixel from your Atlas instead. */
- Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
- pixmap.setColor(1,0,0,.5f);
- pixmap.fill();
- tmpTex = new Texture(pixmap);
- pixmap.dispose();
- /* Setting up the ShapeDrawer. */
- shape = new ShapeDrawer(batch, new TextureRegion(tmpTex));
- }
- @Override
- public void render () {
- /* Clearing the screen and filling up the background. */
- Gdx.gl.glClearColor(0,0,0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- angle += Gdx.graphics.getDeltaTime()/2;
- final float RADIUS = 120;
- Drawable drawable = new ShapeDrawerDrawable(shape){
- @Override
- public void drawShapes(ShapeDrawer shapeDrawer, float x, float y, float width, float height) {
- shapeDrawer.arc(Gdx.graphics.getWidth()/2f,
- Gdx.graphics.getHeight()/2f,
- RADIUS/2, angle, .8f, RADIUS);
- }
- };
- batch.begin();
- drawable.draw(batch, Gdx.graphics.getWidth()/2f, Gdx.graphics.getHeight()/2f, RADIUS*2, RADIUS*2);
- batch.end();
- }
- @Override
- public void dispose () {
- /* Disposing is good practice! */
- batch.dispose();
- tmpTex.dispose();
- skin.dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement