1
Graphics / can't rotate an object around its center even after setting the origin
« on: October 29, 2022, 11:48:18 am »
i'm trying to make an object rotate around its center, so i did this:
the problem is that it doesn't work, and the object still doesn't rotate around the center, even though all solutions i found online say it should work like this.
but there's another weird thing: from what it looks on the sprite (https://www.sfml-dev.org/tutorials/2.5/graphics-sprite.php) tutorial page, textures should resize to what their host sprite's rectangle size is. the fact is that the texture (that I load from file and set using sprite.setTexture(texture)) seems to not do this because I loaded two different sized textures and, setting scale to (1,1), the resulting images on the window were of different sizes. the rescaling still works, but I thought that setting both sizes to (1,1) would make both sprites appear the same size. I'm saying this because this made me think that it could be a problem with this: the sprite's center point is actually being correctly set but the image is too big, so it goes beyond the size of the sprite.
does anyone know what's happening? is it a setOrigin problem or a texture problem? did i misunderstand how either of these work?
also let me know if something wasn't too clear, i probably didn't explain very well
sprite.setOrigin(object.scale * .5);
sprite.setScale(object.scale);
and in a separate function i rotate the object by some amount every framesprite.setScale(object.scale);
the problem is that it doesn't work, and the object still doesn't rotate around the center, even though all solutions i found online say it should work like this.
but there's another weird thing: from what it looks on the sprite (https://www.sfml-dev.org/tutorials/2.5/graphics-sprite.php) tutorial page, textures should resize to what their host sprite's rectangle size is. the fact is that the texture (that I load from file and set using sprite.setTexture(texture)) seems to not do this because I loaded two different sized textures and, setting scale to (1,1), the resulting images on the window were of different sizes. the rescaling still works, but I thought that setting both sizes to (1,1) would make both sprites appear the same size. I'm saying this because this made me think that it could be a problem with this: the sprite's center point is actually being correctly set but the image is too big, so it goes beyond the size of the sprite.
does anyone know what's happening? is it a setOrigin problem or a texture problem? did i misunderstand how either of these work?
also let me know if something wasn't too clear, i probably didn't explain very well