I have some text i want to display in the middle of a sprite, this works fine when the sprite is not rotated but if i rotate the sprite the text gets positioned incorrectly due to the fact that text with a center alignment is the top center compared to sprite's being the actual center.
is there a quick way to work out the correct position of the middle of the sprite after it has been rotated so that text can be placed in the middle (would prefer to use text alignment 1 'middle' but can change if necessary)?
SetVirtualResolution(768,1024)
obj = CreateSprite(0)
SetSpriteSize(obj,100,200)
SetSpritePositionByOffset(obj,386,512)
txt = CreateText("Text")
SetTextAlignment(txt,1)
SetTextSize(txt,80)
SetTextColor(txt,255,0,0,255)
SetTextPosition(txt,GetSpriteXByOffset(obj),GetSpriteYByOffset(obj)-(GetTextTotalHeight(txt)/2))
ang = 0
do
if GetRawKeyReleased(27) then end
inc ang, 1
SetSpriteAngle(obj,ang)
SetTextAngle(txt,ang)
sync()
loop
p.s. i know i can change the sprite's offset to match the text but this will mess up my positioning and moving code so i would prefer it if i can just position the text instead but if it's not
p.p.s. the sprite will rotate in both directions
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu