Can someone explain why Set Y - # works?

0 favourites
  • 3 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • I found a swipe menu demo in Resources. It worked great, except the menu options would scroll right off the page never to scroll again.

    I fiddled around with:

    Event: swipe2 Y <-1000

    Actions: swipe2 Set Y to -1000

    swipe2 Mover forward -(swipespeed/3) pixels

    I set the two actions to -275 and it worked.

    But I don't know WHY it worked and it's bugging me.

    -275 of what?

    Is it -275 of the Margins?

    Or is it -275 from the top or bottom of the screen size?

    I see it all the time, but I don't know why it works.

    I can guess enough to be dangerous.

  • I set the two actions to -275 and it worked.

    I see -1000 on your screenshot. Assuming that this object is on a layer with no parallax, then it's -1000 pixels up from the top edge of the screen.

    If swipe2 object has origin point at the top and you want to restrict its movement by top and bottom edges of the screen, you can use this more universal formula instead of the last two events on your screenshot:

    On every tick: swipe2 set Y to clamp(self.y, ViewportHeight(self.layer)-self.Height, 0)

    A couple of other things:

    Instead of pinning category names to swipe2, add them to a hierarchy in the layout editor.

    Use a single object categoryName with multiple instances instead of 17 different objects.

    Your code is not framerate independent, use delta time. For example: move forward swipespeed*20*dt

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > then it's -1000 pixels up from the top edge of the screen.

    Oh! That makes sense. That's why the distance shortened when I changed it to -275

    Thank you.

    I plan to use hierarchy for the swipe when I build the real thing - this is the test version where I figure out if I can actually build it and work out all the bugs.

    Thanks again.

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