Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I create a camera:

camera = new OrthographicCamera(5.0f, 5.0f * h/w);

Create a sprite:

ballTexture = new Texture(Gdx.files.internal("data/ball.png"));
ballTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
TextureRegion region = new TextureRegion(ballTexture, 0, 0, ballTexture.getWidth(), ballTexture.getHeight());
ball = new Sprite(region);

Set the origin, size, and position:

ball.setSize(0.5f, 0.5f * ball.getHeight()/ball.getWidth());
ball.setPosition(0.0f, 0.0f);

Then render it:


But when I render it, the bottom left of my ball sprite is at (0, 0), not the center of it, as I would expect it to be because I set the origin to the center of the sprite. What am I missing?

share|improve this question
You cross posted this on SO, then posted the answer you got there as your own here. That's not the way we do things here. – Byte56 Jul 6 '12 at 4:04
up vote 2 down vote accepted

setOrigin does not affect translation, only rotation and scaling.

share|improve this answer
As you said, setOrigin() doesn't affect translation, in order to center the sprite at 0,0 you have to setPosition(-w/2, -h/2). Not sure if it is normal to answer your own question in stackoverflow, maybe you have to add a comment instead. – arielsan Aug 24 '12 at 14:24

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.