Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
hyperPad

hyperPad Forum

  1. Home
  2. Help and Support
  3. For Each Tag, order gotten same every time?

For Each Tag, order gotten same every time?

Scheduled Pinned Locked Moved Help and Support
9 Posts 2 Posters 880 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Deeeds
    wrote on last edited by
    #1

    If the number of objects with a given tag doesn't change, does For Each iterate over them in the same order every single time?

    Jack de WildeJ 1 Reply Last reply
    0
    • D Deeeds

      If the number of objects with a given tag doesn't change, does For Each iterate over them in the same order every single time?

      Jack de WildeJ Offline
      Jack de WildeJ Offline
      Jack de Wilde
      wrote on last edited by
      #2

      @Deeeds usually it does but sometimes it doesn't. I've had it change when I've tested after an object, but restarting the project goes back to the original order. I wouldn't rely on it.

      D 2 Replies Last reply
      0
      • Jack de WildeJ Jack de Wilde

        @Deeeds usually it does but sometimes it doesn't. I've had it change when I've tested after an object, but restarting the project goes back to the original order. I wouldn't rely on it.

        D Offline
        D Offline
        Deeeds
        wrote on last edited by
        #3

        @Jack8680 FARK!!!

        That explains what I'm seeing!

        1 Reply Last reply
        0
        • Jack de WildeJ Jack de Wilde

          @Deeeds usually it does but sometimes it doesn't. I've had it change when I've tested after an object, but restarting the project goes back to the original order. I wouldn't rely on it.

          D Offline
          D Offline
          Deeeds
          wrote on last edited by
          #4

          @Jack8680 And is this anywhere near the right way to do something like a parallax pump in hyperPad?

          0_1511416684648_parallaxPump.png

          Jack de WildeJ 1 Reply Last reply
          0
          • D Deeeds

            @Jack8680 And is this anywhere near the right way to do something like a parallax pump in hyperPad?

            0_1511416684648_parallaxPump.png

            Jack de WildeJ Offline
            Jack de WildeJ Offline
            Jack de Wilde
            wrote on last edited by
            #5

            @Deeeds I would use an attribute on the objects in the tag to store their starting x position rather than an array, so it won't rely on the order they are selected in. Also, I think you forgot to select the tags in your move to point behaviou

            I don't fully understand what your screenshot is doing but if I understand what you want correctly, you should be able to do something like:

            For each in [tag]:
                {
                Attribute [tag].StartX = [tag].CurrentX
            
            Function 'parallax DO instruction':
                {
                var ScreenDifference = ScreenCurrentX - ScreenStartX
            
                var ScreenWeightedA = ScreenDifference * ParallaxWeightA
                For each in tag A:
                    {
                    ObjectNewX = ScreenWeightedA + attribute [tag A].ObjectStartX
                    }
            
                var ScreenWeightedB = ScreenDifference * ParallaxWeightB
                For each in tag B:
                    {etc.}
                }
            

            This way the object moves to an offset of its starting position by a multiple of how much the screen has moved (for background layers you'd have the parallax greater than 0 so they move slower than the screen). Here a weight of 0 means it moves like a normal object and a weight of 1 means it sticks with the screen

            Here's a screenshot:

            0_1511486798497_IMG_0520.PNG

            D 4 Replies Last reply
            0
            • Jack de WildeJ Jack de Wilde

              @Deeeds I would use an attribute on the objects in the tag to store their starting x position rather than an array, so it won't rely on the order they are selected in. Also, I think you forgot to select the tags in your move to point behaviou

              I don't fully understand what your screenshot is doing but if I understand what you want correctly, you should be able to do something like:

              For each in [tag]:
                  {
                  Attribute [tag].StartX = [tag].CurrentX
              
              Function 'parallax DO instruction':
                  {
                  var ScreenDifference = ScreenCurrentX - ScreenStartX
              
                  var ScreenWeightedA = ScreenDifference * ParallaxWeightA
                  For each in tag A:
                      {
                      ObjectNewX = ScreenWeightedA + attribute [tag A].ObjectStartX
                      }
              
                  var ScreenWeightedB = ScreenDifference * ParallaxWeightB
                  For each in tag B:
                      {etc.}
                  }
              

              This way the object moves to an offset of its starting position by a multiple of how much the screen has moved (for background layers you'd have the parallax greater than 0 so they move slower than the screen). Here a weight of 0 means it moves like a normal object and a weight of 1 means it sticks with the screen

              Here's a screenshot:

              0_1511486798497_IMG_0520.PNG

              D Offline
              D Offline
              Deeeds
              wrote on last edited by
              #6

              @Jack8680 How'd you do that code tag?

              I only know this one

              1 Reply Last reply
              0
              • Jack de WildeJ Jack de Wilde

                @Deeeds I would use an attribute on the objects in the tag to store their starting x position rather than an array, so it won't rely on the order they are selected in. Also, I think you forgot to select the tags in your move to point behaviou

                I don't fully understand what your screenshot is doing but if I understand what you want correctly, you should be able to do something like:

                For each in [tag]:
                    {
                    Attribute [tag].StartX = [tag].CurrentX
                
                Function 'parallax DO instruction':
                    {
                    var ScreenDifference = ScreenCurrentX - ScreenStartX
                
                    var ScreenWeightedA = ScreenDifference * ParallaxWeightA
                    For each in tag A:
                        {
                        ObjectNewX = ScreenWeightedA + attribute [tag A].ObjectStartX
                        }
                
                    var ScreenWeightedB = ScreenDifference * ParallaxWeightB
                    For each in tag B:
                        {etc.}
                    }
                

                This way the object moves to an offset of its starting position by a multiple of how much the screen has moved (for background layers you'd have the parallax greater than 0 so they move slower than the screen). Here a weight of 0 means it moves like a normal object and a weight of 1 means it sticks with the screen

                Here's a screenshot:

                0_1511486798497_IMG_0520.PNG

                D Offline
                D Offline
                Deeeds
                wrote on last edited by
                #7

                @Jack8680 I've got mine working, it's almost exactly as you're describing: 0 = fixed like a normal object, the higher the value the "deeper" it is back from the camera, hence using Depth to describe their position.

                And the sequencing through the tags (Loop For Each) is seeming to work just fine.

                I went this way in the off chance it might work, for a few reasons.

                1. I love arrays. And figured this would be the fastest way
                2. I have a suspicion that looking up tags is a proper property value hunt underneath (slower)
                3. I intend to add lots more objects and depths and effects to this, so want the performance
                4. I'm using teleporting at each "end" of the "world", for which these arrays are something I'm going to use to mirror some objects at each end around to the other end so that there's a seamless switch

                But, having said that, I haven't taken the time to really grok what you're doing with tags and attributes and how that alleviates any potential order issues, and what that might mean for adding content to the backgrounds dynamically (something else I'm considering).

                1 Reply Last reply
                0
                • Jack de WildeJ Jack de Wilde

                  @Deeeds I would use an attribute on the objects in the tag to store their starting x position rather than an array, so it won't rely on the order they are selected in. Also, I think you forgot to select the tags in your move to point behaviou

                  I don't fully understand what your screenshot is doing but if I understand what you want correctly, you should be able to do something like:

                  For each in [tag]:
                      {
                      Attribute [tag].StartX = [tag].CurrentX
                  
                  Function 'parallax DO instruction':
                      {
                      var ScreenDifference = ScreenCurrentX - ScreenStartX
                  
                      var ScreenWeightedA = ScreenDifference * ParallaxWeightA
                      For each in tag A:
                          {
                          ObjectNewX = ScreenWeightedA + attribute [tag A].ObjectStartX
                          }
                  
                      var ScreenWeightedB = ScreenDifference * ParallaxWeightB
                      For each in tag B:
                          {etc.}
                      }
                  

                  This way the object moves to an offset of its starting position by a multiple of how much the screen has moved (for background layers you'd have the parallax greater than 0 so they move slower than the screen). Here a weight of 0 means it moves like a normal object and a weight of 1 means it sticks with the screen

                  Here's a screenshot:

                  0_1511486798497_IMG_0520.PNG

                  D Offline
                  D Offline
                  Deeeds
                  wrote on last edited by
                  #8

                  @Jack8680 Which is also me saying

                  THANK YOU!!!

                  I'm going to cogitate on this as I struggle with some other aspects of getting the visual feel I want.

                  1 Reply Last reply
                  0
                  • Jack de WildeJ Jack de Wilde

                    @Deeeds I would use an attribute on the objects in the tag to store their starting x position rather than an array, so it won't rely on the order they are selected in. Also, I think you forgot to select the tags in your move to point behaviou

                    I don't fully understand what your screenshot is doing but if I understand what you want correctly, you should be able to do something like:

                    For each in [tag]:
                        {
                        Attribute [tag].StartX = [tag].CurrentX
                    
                    Function 'parallax DO instruction':
                        {
                        var ScreenDifference = ScreenCurrentX - ScreenStartX
                    
                        var ScreenWeightedA = ScreenDifference * ParallaxWeightA
                        For each in tag A:
                            {
                            ObjectNewX = ScreenWeightedA + attribute [tag A].ObjectStartX
                            }
                    
                        var ScreenWeightedB = ScreenDifference * ParallaxWeightB
                        For each in tag B:
                            {etc.}
                        }
                    

                    This way the object moves to an offset of its starting position by a multiple of how much the screen has moved (for background layers you'd have the parallax greater than 0 so they move slower than the screen). Here a weight of 0 means it moves like a normal object and a weight of 1 means it sticks with the screen

                    Here's a screenshot:

                    0_1511486798497_IMG_0520.PNG

                    D Offline
                    D Offline
                    Deeeds
                    wrote on last edited by
                    #9

                    @Jack8680

                    I think I've grokked what you're doing.

                    Each object stores its original position in an Attribute, each run through the loop this is gotten and used for the calculation.

                    I've believed in arrays, stuffed them full of each objects' original positions and hoped for the For Each loop to go through in the same order each time, since I'm using the index to grab those original positions, they aren't tied to their original object.

                    This will probably lead to catastrophe at some point, when I'll need to use your approach.

                    1 Reply Last reply
                    0

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Search