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

0 favourites
  • 9 posts
From the Asset Store
Set of tiles to create a map for top-down games with island theme
  • 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.

  • Still need a reply to this. I can't believe there is no way to do it...

  • You are creating interface, right?

    Create new layer, put it on top, change parallax X & Y to 0.

  • 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?

  • 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 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.

    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.

    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!

  • 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..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)