How do I Center dynamic text on a hud layer

Get help using Construct 2

Post » Mon Feb 29, 2016 1:40 pm

Hi all

I have a hud layer which of course I do not want to move while the camera then scrolls around my layout.

However I want messages as text to appear in the centre of the screen on all size devices.

I have tried to make sense of the mish mash of tutorials and comments on how to do this, but it never seems to work correctly. At the moment I have a HUD layer, and my text object has an anchor behaviours on it.
I tried then setting this to a position but learn anchors ignore this so when i set X as WindowWidth/2 - Self.TextWidth/2 it does absolutely nothing.

So how can I guarantee that when this text object contains the string "Welcome" it is centre of the screen, and also when it contains the string "Loriem Ipsum dipsum do" of a different length this is also centered?

At the moment I have an anchor behaviour added, and hotspots and horizontal align all set to center.
But its never center when i load it on different screens/browser widths.

thanks for any guidance.
B
7
S
1
Posts: 34
Reputation: 525

Post » Mon Feb 29, 2016 1:55 pm

I think i have solved it, it was user error.

My window is 640, but i thought it was 800.

So with window been 640, i set my text as follows..

Add anchor object
Make Horizontal align center.
Make hotspot center.
position is 320.

Hope this helps someone else.
B
7
S
1
Posts: 34
Reputation: 525


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests