Sign up ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Dear Fellow Game Developers
i am newbie to Android Game Development,i like to know how we can develop a sprite rotate in circle on android,with help of libgdx, i do have a image in assets folder,cant load it in emulator,following code is using to load image in texture

texture = new Texture(Gdx.files.internal("1325603701_wordpress.png"));

share|improve this question
Are you having issues to load the texture or rotate the sprite? –  Gustavo Maciel Jan 8 '12 at 20:21
in both...i dont get image or rotate sprite –  Alex Mathew Jan 15 '12 at 18:53
Did you check for the answer and did you find the solution? –  ManishSB Aug 11 '14 at 13:42

4 Answers 4

Create your sprite as following

Texture glowBlock = new Texture(Gdx.files.internal("data/glow-block.png"));
Sprite  glowSprite = new;

Then in your render method do this

public void render () {;
    glowSprite.rotate((float) 45.0);
    glowSprite.draw(spriteBatch, 100);

That should give you sprite rotated for 45 degrees

share|improve this answer
Is it working for you? –  ManishSB Aug 11 '14 at 13:42

Here is the simple way how can you rotate a sprite in libGDX. First you need to set the origin:


Then you can rotate clockwise and anticlockwise according to your need:

sprite.rotate(2f); or sprite.rotate(-2f);
share|improve this answer

If by rotating in a circle you mean WALKING on top of the circumference of a circle, then I guess any of the answers correctly answered your question. So here is my add:

You can continue loading you texture with

texture = new Texture(Gdx.files.internal("1325603701_wordpress.png"));

but it is extremely recommended that you use the AssetManager. About it not loading in the emulator, check if your texture size is power of two. (Like 64x64)

Then create your sprite:

sprite = new Sprite(texture);

you'll possibly want to pass more arguments to cut the sprite, in case you're using a power of two texture for a non power of two sprite.

Create a helper variable on the class body, to keep track of the time, and one to say where will be the sprite center:

private float elapsedTime = 0.0f;
private Vector2 center = new Vector2(10, 10);

on render:

public void render () {
    final float speed = 30.0f; // in degrees per second
    final float radius = 10.0f; // the radius of the circle you'll be rotating
    float angle = elapsedTime * speed;;
    sprite.setRotation(angle - 90);
    sprite.setPosition(center.x + radius * (float)Math.cos(angle * MathUtils.degrad), center.y + radius * (float)Math.sin(angle * MathUtils.degrad));

This should work just fine.

share|improve this answer

Do it like this 1. Load your image into AssestLoader class and store it in sprite

sprite=new Sprite(AssestLoader.1325603701_wordpress);

2.Then set its size , position and color like this

sprite.setColor(1, 1, 1, 1);
sprite.setPosition((w / 2) - (sprite.getWidth() / 2), (h / 2)
                - (sprite.getHeight() / 2));

3- In your render method use the below code


4.Call the rotate method where u want to rotate



public void rotate(float angle)


where deltatime is float value=1

Hope this Helps You.

share|improve this answer
This is so bad it's hard to know where to start. Firstly asset manager is off topic to the questiin. Even then your code example is almost senseless. What is this AssestLoader? Then you set the sprite size using its current size.: nonsensical. You then, for some reason hard code an increase in delta time... Which makes no sense - in libgdx talk delta time is the time between frames. Finally you create a redundant rotate function which accesses a global. Horrible. . –  RichieHH Jan 15 at 1:18
I will just edit the answer in while, sorry for inconvinience @RichieHH –  ManishSB Jan 15 at 12:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.