Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Rotate text with sprite

Author
Message
MateiSoft
12
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 22nd Feb 2019 09:14 Edited at: 22nd Feb 2019 09:14
Hello guys,

I have a little problem regarding text rotation and sprite rotation. I want the text to rotate in the same way and angle that the sprite does. Is there any formula or just a command? I tried using setspriteoffset, but no luck.

Here is a video with the problem:

https://youtu.be/RmXyY-zfEaQ

Thank you very much!
www.alexmatei.com

The author of this post has marked a post as an answer.

Go to answer

chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Feb 2019 09:23
I think if the text is a sprite, both sprite has to have the centered offset and the same sprite position x,y
I'm not a grumpy grandpa
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 22nd Feb 2019 09:31 Edited at: 22nd Feb 2019 09:33
Best to use something like GetWorldXFromSprite and GetWorldYFromSprite and set the position of the text so that it stays in the same place on the sprite.

Really quick example...

chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Feb 2019 09:56
Thanks Bengismo...we learn a bit every day
I'm not a grumpy grandpa
MateiSoft
12
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 22nd Feb 2019 14:30 Edited at: 22nd Feb 2019 14:30
Hello Chafari, long time!

Thank you Bengismo!

One last question: If I have different sprites with different sizes, to position the text in the center, instead of -12, what's the universal value to put, or formula?

Thank you again Bengismo and Chafari!
www.alexmatei.com
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 22nd Feb 2019 14:41 Edited at: 22nd Feb 2019 14:42
This post has been marked by the post author as the answer.
The -12 is compensating for the height of the text. The value used for the Y offset should be half the text height

So using the same example code:



It then works no matter what the size of the sprite or the text is.

i actually used 0.55 instead of 0.5 as it centres the text vertically slightly better in my opnion.
MateiSoft
12
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 22nd Feb 2019 15:11
Absolutely perfect!

Thank you for the explanation and for the example! Cheers to both of you!
www.alexmatei.com

Login to post a reply

Server time is: 2024-11-05 23:03:16
Your offset time is: 2024-11-05 23:03:16