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.

Newcomers AppGameKit Corner / rotate text by center

Author
Message
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 20th Dec 2017 12:47
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)?

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
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Dec 2017 16:12
Can you make the text and sprite one image?
You can paste both sprites and then getImage to create it.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
nonom
6
Years of Service
User Offline
Joined: 12th Nov 2017
Location: Picking mushrooms
Posted: 2nd Jan 2018 13:05
@smallg did you meant this?

IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 2nd Jan 2018 16:41 Edited at: 2nd Jan 2018 17:35
This isn't quite perfect but it works I think.

smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 2nd Jan 2018 20:01
@nonom not quite, i wanted to keep the offset of the sprite in the center
@ironmanhood that works much better, thanks!
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu

Login to post a reply

Server time is: 2024-04-24 06:26:54
Your offset time is: 2024-04-24 06:26:54