mardi 4 août 2015

Draw circle countdown with the libgdx

I am prety new on LibGDX,and trying to create a circle which shows the remaning time of the game.For that purpose I find this called RadialSprite,but dont know how to apply it. what I have treid so far like this.

@Override
    public void render(float delta) {
        // TODO Auto-generated method stub

         Texture txturecircle = new Texture(Gdx.files.internal("circle.png"));;

         TextureRegion regions= new TextureRegion(txturecircle);
         RadialSprite rd=new RadialSprite(regions);

        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        batch.begin();

        rd.draw(batch, 100, 10,0);
        batch.end();   
        stage.draw();
        stage.setDebugAll(true);


    }

My update function which create images again depents on the remaning time of the game.

int time = 0;
    @Override
    public void show() {
        // TODO Auto-generated method stub
        com.badlogic.gdx.utils.Timer.schedule(new Task() {

                    @Override
                    public void run() {
                       DrawTimer();

                    }
                }, 1,1);
    }
    private void DrawTimer() {
         Texture txturecircle = new Texture(Gdx.files.internal("circle.png"));;

         TextureRegion regions= new TextureRegion(txturecircle);
         RadialSprite rd=new RadialSprite(regions);
        Log.d("tımer",String.valueOf(time));
        batch.begin();
        time++;
        rd.draw(batch, 90, 110, 36*time);
        batch.end();

    }

**Iam trying to do something like this. enter image description here

any help or direction wellcome



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire