Hey Everybody,
I thought I'd share this function I just wrote for my WIP
TextAlongLine(iTextID, fX1, fY1, fX2, fY2)
function TextAlongLine(ids,x1 as float,y1 as float,x2 as float,y2 as float)
tal_chars as float
tal_dist as float
tal_cdist as float
tal_height as float
tal_angle as float
`
setTextPosition(ids,x1,y2)
`
`
tal_chars=Len(GettextString(ids))
tal_dist=sqrt((x1 - x2)^2 + ((y1-y2)/1.0)^2)
tal_cdist=tal_dist/tal_chars
tal_angle=atanfull(x2 - x1, y2 - y1)
tal_height=GetTextTotalHeight(ids)
`
for k=1 to tal_chars
SetTextCharPosition(ids,(k-1),(cos(tal_angle)*(tal_cdist*(k-1))),(sin(tal_angle)*(tal_height*(k-1))))
SettextCharAngle(ids,k-1,tal_angle)
next
endfunction
My Trig isn't the best, so this function could probably be done better.
I'm sure many of you will find this useful.
btw, is the UCF project still active?
If so I'll add this there and a mod can lock/delete this post if they wish
EDIT: Whoops, it's TextAlongLine, not SetTextAngle
EDIT2: Important!!! This is made for a game where the aspect ratio of the x/y
pixels is 1/1
ie. Anything done with SetVirtualResolution
If you use the other one (forget it's name
, the one where the res is 100x100 no matter what ), you must change this line:
tal_dist=sqrt((x1 - x2)^2 + ((y1-y2)/1.0)^2)
Change the 1.0 to whatever your aspect ratio might be (1.5 is a good bet)