The Daily Click ::. Forums ::. Klik Coding Help ::. String Object hotspots?
 

Post Reply  Post Oekaki 
 

Posted By Message

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
11th March, 2012 at 11/03/2012 08:25:12 -

Hello,

Has anybody figured a way to change the "hotspot" position of a string object?

For example, say you have a string object, 100 pixels wide and with centred horizontal alignment. You want this string object to be positioned above your player. So you set the X position of your string to the X position of your player. The problem is, even though your string has centre alignment, it will not appear at the centre of your player because the hotspot of string objects is at their top left corner.

http://www.whenthereisnoroominhellthedeadwalktheearth.com/MMF/problem.mfa

 
n/a

nim



Registered
  17/05/2002
Points
  7233
11th March, 2012 at 11/03/2012 14:08:35 -

Couldn't you just make the String object really wide and center-align the text within it? If the String object is 400px wide then always set its x-coord to X("Player")-200.

If you don't want to do that, you could stick to using a fixed-width font and calculate it from there.

If you don't want to do THAT, there's also a nice extension called Text Rect that will calculate the dimensions of a text box's content at runtime.

 
//

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
12th March, 2012 at 12/03/2012 02:37:17 -

A font with a fixed character width would be a great idea but I am dead set on Arial haha.

I'll check out that Text Rect extension. Sounds like what I'm after. Thanks for the advice.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click