positioning objects relative to window

0 favourites
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I don't get it. I thought I got it, but I don't :)

    How do I position objects on its creation in the top left corner of the viewport when using fullscreen: scale option. I thought that (assuming it's 640x480) x=320-windowWidth/2, y=240-windowHeight/2 shoud work. But it didn't.

    Thanks in advance.

  • Make a "HUD" layer with parallax 0,0, then stick it on that layer at 0,0.

    Otherwise, use the scrollx and scrolly expressions.

  • and if I must position this objects on a layer that has parallax = 100 and scale = 100? scrollx and scrolly will give me 320 and 240 (half of the window size which I already know) so that doesn't help.

  • To top-left corner use:

    set X to scrollX - windowWidth/2

    set Y to scrollY - windowHeight/2

  • again, no :(

    here's capx:

    mediafire.com

    after 4 seconds the plack box should appear in the top left corner right? well it doesn't :) halp plox :) cheers!

  • but this object will have movement behaviors and all. I want to position it in the top left only once, without using any behaviors. so again, my question, to be as specific as I can:

    how to position my object on creation in the top left corner of the viewport using "set position" action, on a layer that has parallax and scale set to 100.

    sorry to be pain in the arse, but please understand, nobody understands me, boo hoo :( :)

  • The anchor is a behavior designed to place objects on a screen position (when the layout/layers are scaled) and keep them there.

    What do you mean "movement behavior" ?

    You're not expressing your idea or what you're trying to achieve clearly.

    The anchor behavior answers the question "how to position my object on creation in the top left corner of the viewport using "set position" action, on a layer that has parallax and scale set to 100."

  • forgot to add "NOT using ANY behaviors". that's what I'm trying to achieve, I'm trying to:

    position my object on creation in the top left corner of the viewport using "set position" action, on a layer that has parallax and scale set to 100 NOT using ANY behaviors.

    also, of course, bug thanks for trying to help me out with this :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why "without any behavior" when the simplest and most efficient way is to use the dedicated behavior ?

  • because I hope it's easy and nobody will ask why and just answer. this was tldr version :) the real reason is because this sprite will have a custom movement based on moving towards other sprites scattered through playfield and the anchor behavior will collide with the custom movement behavior, they just won't work together. also, I beg you, how do I get an answer to my question without being rude, I really have a dream that someday, I come here, ask question and just get working answer without waiting whole day, explaining that answers provided by some don't work, to others why am I tryind to achieve this and why this and not other way. really didn't mean to be rude in any way and of course I'm super grateful for any input at all, but still hoping to get a good answer at some point. cheers!

  • Animmaniac's solution should have worked. It appears to be a bug that it doesn't work with "fullscreen on(scaled)" as it works with "fullscreen off" and "fullscreen on (crop mode)". To be exact the scrollx and scrolly expressions are returning a position that's in the center of the screen but doesn't seem to have a correlation to the screen size.

    Now for a workaround select "fullscreen on (crop mode)" and set the scale manually. Then use these actions:

    Set layout scale to: min(WindowWidth/640,windowheight/480)

    Sprite set x: scrollX - WindowWidth/(LayoutScale*2)

    Sprite set y: scrollY - WindowHeight/(LayoutScale*2)

  • ok, thanks a bunch for that, also posting this as a bug in bugs. thanks again, cheers!

  • Eureka,

    I realized it was a different issue. In your capx use the edittime windowwidth and windowheight values for positioning.

    For ex. it would be

    Sprite set x: scrollX - 640/2

    Sprite set y: scrollY - 480/2

    So you would do the math as if the window were not scaled at all.

    Edit:

    Actually it looks like no issue at all. I thought it was because with unbounded scrolling off scrollx and scrolly were returning 479.25 and 240, but it seems to be correct.

  • ok, and if you do check the unbounded scrolling on, what then? how to position the object the way that I want to from the start?

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