How do I position a sprite in the center of the screen region?

0 favourites
  • 7 posts
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • hi, forgive the noob question but

    sounds simple cant find the answer anywhere here or in videos... so probably i am asking google the wrong way.

    in c2 we have this "window" region. lets say is 1920x1080

    i want to position a sprite in the center of it, and lets say the sprite the dimensions of 250 x 100.

    whats the easiest way to do that?

    thanks in advance.

  • it happened again....you search for hours....no results you make a post... you search again and find something that worked! damn it.

    for any other poor soles out there

    x=scrollx

    y=scrolly

    now why the name "scroll" will give you the center and who decided to not mention that in the documentation is beyond my understanding.

  • Was it your player that had to be centered? I am not sure you really want to use Scroll X/Y - that centers your camera on the object.

    'Set X' to 'ViewportWidth(0)/2' and 'Set Y' to 'ViewportHeight(0)/2'

    That will center you sprite to your screen. The (0) is the layer number I guess.

  • thanks for the tip, but no it was not my "player"

    i just wanted to show a sprite with some nice graphics when you WIN the level or when you LOSE.

    just show the sprite in the center of the screen. i don't know if there is another way to a "message" like that :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, ok. Well there is lot of different ways to do what you want to achieve.

    I would make a layer on top of all the other layers and turn the visibility on and off when you need to show the message (text/sprite/whatever). You can have a lot of different message layers like that.

    Btw, I forgot to mention in the last post that your pivot point on your Sprite has to be centered too.

  • if i was using layers, doesn't that mean that i must have all my dialog sprites already preCenter from the designer?

    but yeah i guess if i have a lot or i know exactly where they should be layers is a good organized idea.

    but for now i just had this 2. Thanks a lot for the tip will put into good use!

  • I think this is easy to incorporate if you are new to all of this. Glad I could help.

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