rotating menu with Actors in libgdx

Posted by joecks on Game Development See other posts from Game Development or by joecks
Published on 2012-06-26T16:10:54Z Indexed on 2012/06/26 21:26 UTC
Read the original article Hit count: 250

Filed under:
|
|

I am intending to build a circular menu, with menu items equally distributed around the circle. When clicking on a menu item the circle should rotate so that the selected item is facing the top. I am using libgdx and I am not very familiar with the Actors concept, so I intuitivly tried to implement an Actor, who is drawing a texture and then transforming it by using Actions, with no success:

    class CircleActor extends Actor {

    @Override
    public void draw(SpriteBatch batch, float parentAlpha) {
        batch.draw(texture1, 100, 100);
    }

    @Override
    public Actor hit(float x, float y) {
        return this;
    }

}

and the rotate action:

    CircleActor circleActor = new CircleActor();
    circleActor.action(Forever.$(RotateBy.$(0.1f, 0.1f)));
    // stage.addActor();
    stage.addActor(circleActor);

The texture is rectangular, but it doe not work. 1. What is wrong? 2. Is it a good approach to solve the task?

Thanks!

© Game Development or respective owner

Related posts about java

Related posts about libgdx