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.

If I scale a sprite at its centre, then try to rotate it around its centre as well, the rotation does not occur around its centre.

If you need to rotate, for example a scaled ball,the way its working it is set the scale center at the top left (0,0) set the scale that you want, and then set the rotation center to the middle of the scaled sprite, and then apply the rotation modifier.

blaBloBliSprite.setScaleCenter(0, 0);
blaBloBliSprite.setScale(0.667f);
blaBloBliSprite.setPosition(557, CAMERA_HEIGHT / 2 - blaBloBliSprite.getHeightScaled() / 2);
blaBloBliSprite.setRotationCenter(blaBloBliSprite.getWidthScaled() / 2, blaBloBliSprite.getHeightScaled() / 2);

But I want to scale a sprite at its centre as well.

Is there any way of doing it?

share|improve this question
1  
What technology are you using? How is rotation and scale stored and computed? This question is not very helpful, all I can read is "THIS NO WORK, NEED HELP" It can be done in a million ways... –  rioki Apr 23 '13 at 14:43
    
I don't think any new thing you have to do for this. Default rotation center is middle of any sprite. So you don't have to set it manually. If you found any thing wrong again then you have to become more precise about you question so we can understand more better. –  Siddharth Apr 23 '13 at 17:18

2 Answers 2

You are setting rotation center in the world, not on the sprite. So if you set rotation centre to (0, 0) the sprite will rotate around left corner of the screen. You must set the rotation center similar to this:

float centerX = sprite.getX() + sprite.getWidth() / 2;

share|improve this answer

There isn't enough information to solve this - we have no idea what any of those functions do. Is this custom software? Is it technology from someone else?

I don't understand why one even needs a "scale center". It all seems like an overly complicated piece of tech for something so simple.

Try setting the rotation centre with the unscaled width/height. It's extremely likely that the technology does the rotation before scaling. As such, you're scaling the centre twice which would offset your centre and cause the bad rotation and possibly positioning.

share|improve this answer
5  
OP is using andengine and this isn't really much of an answer. –  bummzack Apr 25 '13 at 14:30

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.