使用libgdx绘制圆倒计时

时间:2015-08-04 12:34:27

标签: java android libgdx

我是LibGDX的新手,并试图创建一个显示游戏重播时间的圆圈。为此,我发现这个名为RadialSprite,但不知道如何应用它。 我到目前为止所做的就是这样。

public class GameAreaScreen implements Screen{


    Skin skin;
    Stage stage;
    Table table= new Table(); 
    int a,b,c,result;
    float bosluk=2;


    private TextField txtFieldOperator;
    private TextField txtFieldC;
    private TextField txtFieldA;
    private TextField txtFieldB;
    private TextField txtFieldEqual;

    private float time=10;
    private RadialSprite rd;
    private MyGdxGame game;

    public GameAreaScreen(final MyGdxGame gam){
        this.game=gam;
        create();

    }



    public void create(){

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

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

          stage = new Stage();
         Gdx.input.setInputProcessor(stage);

         Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));  

          txtFieldA= new TextField("a Vallue", skin);
          txtFieldB= new TextField("b Vallue", skin); 
          txtFieldC= new TextField("c Vallue", skin);
          txtFieldOperator= new TextField("op", skin);
          txtFieldEqual= new TextField("=", skin);

         table.add(txtFieldA).pad(bosluk).width(30);
         table.add(txtFieldOperator).pad(bosluk).width(30);
         table.add(txtFieldB).width(30);
         table.add(txtFieldEqual).pad(bosluk).width(30);
         table.add(txtFieldC).pad(bosluk).width(30);

         table.setFillParent(true);

        // stage.addActor(table);

    }

    @Override
    public void show() {
        // TODO Auto-generated method stub

    }

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

            time -= delta; 

        rd.setAngle(time/10f * 360f);

        Log.d("TIME",String.valueOf(time));
        Log.d("angel",String.valueOf(rd.getAngle()));

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


        game.batch.begin();
        rd.draw(game.batch, 100,100,36);
        game.batch.end();

        //stage.draw();  

        //stage.setDebugAll(true);


    }


    @Override
    public void resize(int width, int height) {
        // TODO Auto-generated method stub

    }

    @Override
    public void pause() {
        // TODO Auto-generated method stub

    }

    @Override
    public void resume() {
        // TODO Auto-generated method stub

    }

    @Override
    public void hide() {
        // TODO Auto-generated method stub

    }

    @Override
    public void dispose() {
        // TODO Auto-generated method stub

    }

MyGdxGame类

public class MyGdxGame extends Game{


    SpriteBatch batch;
    BitmapFont font;

    public void create() {
        batch = new SpriteBatch();
        // Use LibGDX's default Arial font.
        font = new BitmapFont();
        this.setScreen(new MenuScreen(this));
    }

    public void render() {
        super.render(); // important!
    }

    public void dispose() {
        batch.dispose();
        font.dispose();
    }


}

**我试图做这样的事情。 enter image description here

任何帮助或方向的好处

0 个答案:

没有答案