Anchor in center

Get help using Construct 2

Post » Thu Feb 14, 2013 10:47 pm

Hi guys,

I was surprised to find that anchor behaviour can not center the HUD without scaling it.

Whats the best way to position HUD element in bottom center for example, in multiple screen sizes?

Thanks
B
2
Posts: 18
Reputation: 286

Post » Fri Feb 15, 2013 12:08 pm

Can anyone help?
B
2
Posts: 18
Reputation: 286

Post » Tue Feb 26, 2013 6:21 pm

I'm also looking for this, it seems pointless to have the other anchor options without the ability to set my main game window to the middle (I don't want it to change size, would affect gameplacy).
B
20
S
6
G
2
Posts: 157
Reputation: 3,109

Post » Tue Feb 26, 2013 6:51 pm

When I wanted to centre a element to screen I set it's position to X: (WindowWidth/2) - (Self.Width/2) and Y: (WindowHeight/2) - (Self.Height/2) and you can attach it to a layer that has zero scaling set, it will be the same size across all displays.

I use Self.Wdith/2 because my origin for the element is in the centre, but if you moved it to top left for example you don't need that.labithiotis2013-02-26 18:52:30
B
24
S
11
G
5
Posts: 140
Reputation: 5,004

Post » Wed Feb 27, 2013 11:01 am

Well, this works if you don't use Anchor
If you do use it you cant move the sprite.
I think the anchor behavior should be tweaked
B
12
S
3
G
1
Posts: 120
Reputation: 1,829

Post » Wed Feb 27, 2013 2:08 pm

I have experimented with setting positions at startup, but unless I am missing something this just breaks if you resize the window e.g. in a browser.

I don't really want to have to code two versions of the same game for mobile and PC.

C2 has so much potential I am surprised by the holes in layout options. There should be support for multiple layouts (mobile port, land), and support for "window resize" event.
silkc22013-02-27 14:08:19
B
20
S
6
G
2
Posts: 157
Reputation: 3,109

Post » Tue Jul 28, 2015 9:26 pm

Hello this problem was solved?
B
7
S
1
Posts: 24
Reputation: 430

Post » Wed Jul 29, 2015 3:49 am

you can have an event that re positions it on every tick. make an invisible sprite called "center" then it will always remain in the center if you use the the position code as stated above, and you can align other objects to it as necessary.
B
50
S
21
G
8
Posts: 844
Reputation: 10,299


Return to How do I....?

Who is online

Users browsing this forum: jeffige and 24 guests