Take the 2-minute tour ×
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
add comment

2 Answers 2

Create your sprite as following

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

Then in your render method do this

@Override
public void render () {
    Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);
    spriteBatch.begin();
    spriteBatch.setColor(Color.WHITE);
    glowSprite.rotate((float) 45.0);
    glowSprite.draw(spriteBatch, 100);
    spriteBatch.end();
}

That should give you sprite rotated for 45 degrees

share|improve this answer
add comment

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

sprite.setOrigin(sprite.getWidth/2,sprite.getHeight/2);

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

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

Your Answer

 
discard

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.