How do I Anchor the bottom of a sprite to the top

Get help using Construct 2

Post » Sat May 30, 2015 3:38 pm

Hi everyone,

I would like to anchor the bottom of a sprite to the top of the window, but in "bottom edge" (anchor behavior) there is only "Window bottom" and "none" which are selectionnable. This is weird, as in the "top edge" there is "window top", "window bottom" and "none"

Is there a way to anchor the bottom of a sprite to the top of the window in another way?
This is for vertical gauge which origin should be at the bottom.
B
24
S
5
G
1
Posts: 336
Reputation: 2,433

Post » Mon Jun 01, 2015 3:20 pm

Still need a reply to this. I can't believe there is no way to do it...
B
24
S
5
G
1
Posts: 336
Reputation: 2,433

Post » Mon Jun 01, 2015 3:51 pm

You are creating interface, right?

Create new layer, put it on top, change parallax X & Y to 0.
I'm a Magician, not a Developer.
B
21
S
8
G
25
Posts: 105
Reputation: 14,252

Post » Mon Jun 01, 2015 8:04 pm

@XpMonster
Thanks for the reply. Yes it is for an interface (gauge), but defining the parallax to 0,0 produces weird results.
As it is a mobile game, I created a larger layout in order to fit all screen sizes. So at the beginning of the layout, I'm scrolling down to align the bottom of my window with the bottom of the layout. When using your method, the objects starts moving everywhere on the screen when screen format changes (4/3 and 16/9 gives not the same result). Seems like I'll need an anchor in this case...

Any other way?
B
24
S
5
G
1
Posts: 336
Reputation: 2,433

Post » Mon Jun 01, 2015 8:25 pm

And did you change scale to 0?

I don't think anchor will help. For some kind of screen format you will have to change position of objects yourself.

You also can add in options of your game customization of the interface, where players will be able to change position and opacity of it or just choose one of templates you've created.
I'm a Magician, not a Developer.
B
21
S
8
G
25
Posts: 105
Reputation: 14,252

Post » Tue Jun 02, 2015 10:14 am

I tried to put scale to 0 and it didn't change anything. My object is still placed at very different places depending on the screen format.

XpMonster wrote:I don't think anchor will help. For some kind of screen format you will have to change position of objects yourself.


I politely disagree. I'm using anchors for all the other elements of my HUD and it's working perfectly. Even when I change the format of my screen in real time by stretching a browser window like crazy, everything stays at the correct place. My only problem is that the option to anchor the bottom of an object to the top of the window apparently doesn't exist (why?) so that's it's pretty difficult to place a vertical jauge at the top of the screen in my case.

XpMonster wrote:You also can add in options of your game customization of the interface, where players will be able to change position and opacity of it or just choose one of templates you've created.


I won't do this, sorry. I want the HUD to adapt automatically to screen resolution, not asking the player what resolution he plays in. If there is really no way to anchor the bottom of an object to the top of the screen, I'll design my HUD in a different way, but it would be too bad!
B
24
S
5
G
1
Posts: 336
Reputation: 2,433

Post » Tue Jun 02, 2015 10:23 am

I'm not sure why anchoring the bottom to the top would be so imortant, but anyway

Instead of using the anchor behaviour you could always just set the position of your objects (this should only have to be done once)..

Using viewportleft(), Viewportright(), viewporttop(), Viewportbottom() positioning the object to the right location on a non paralax layer should be simple..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jun 02, 2015 11:14 am

I will be able to help you more if i'll know what exactly do you need.
What HUD do you like to create in your game and etc. - screenshot will do.

More designer then programmer.
I'm a Magician, not a Developer.
B
21
S
8
G
25
Posts: 105
Reputation: 14,252

Post » Tue Jun 02, 2015 12:19 pm

Thank you @XpMonster and @LittleStain for your replies.

Oh great! I didn't know it was possible to define an object position in regards to the viewport top border! It should do the trick! :)

Anchoring bottom of an object to top of the viewport is important because it allows to place a vertical gauge that depletes from top to bottom. If I anchor top to top, the gauge moves as soon as its value change, so that the top is always aligned with the defined point, resulting in the gauge depleting from bottom to top.

But your trick should be okay, I'll try it tonight! Thanks again!
B
24
S
5
G
1
Posts: 336
Reputation: 2,433


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest