I almost always do a
sprite.SetImage(image);
sprite.SetPosition(400, 300);
sprite.SetCenter(sprite.GetSize()/2.f);
To have the sprite centered.
But if the sprite has some scale, i.e.:
sprite.SetImage(image);
sprite.SetPosition(400, 300);
sprite.SetScale(0.8f, 0.8f);
sprite.SetCenter(sprite.GetSize()/2.f);
It doesn't get centered correctly. GetSize() returns the corrected size given the sprite's scale, but I think that's something wrong with the centering on sprite drawing (maybe other shapes too)... as I would expect what I wrote to work.
In the docs it says: Set the center of the object, in coordinates relative to the top-left of the object (take 2 values).
So I get that those are not Image coordinates, but object's (drawable) ones.
But doing:
sprite.SetCenter(image.GetWidth()/2.f, image.GetHeight()/2.f);
works as you would think the previous code would.
Is this the expected behaviour? If it is, it would be nice to document that the center is taken as image-coords instead of object coords.
Thanks
-MartÃn