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. The best way to dynamically spawn a list of buttons?

The best way to dynamically spawn a list of buttons?

Scheduled Pinned Locked Moved Help and Support
10 Posts 4 Posters 1.8k 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.
  • KamdroidK Offline
    KamdroidK Offline
    Kamdroid
    wrote on last edited by
    #1

    I am wondering if anyone has any good idea on how to dynamically spawn a list of buttons.

    These are the two ideas I have came up with:

    • Use a timer with a slight delay and set an attribute that the label will set to once spawned (pretty slow)

    • Use Loop behaviour and use receive and broadcast behaviours based on the label's location to send it the information

    These are both pretty bad workarounds, so does anyone know anything better, or will I just have to wait for hyperPad to add support to object referencing?

    Aidan_FireA D 3 Replies Last reply
    0
    • KamdroidK Kamdroid

      I am wondering if anyone has any good idea on how to dynamically spawn a list of buttons.

      These are the two ideas I have came up with:

      • Use a timer with a slight delay and set an attribute that the label will set to once spawned (pretty slow)

      • Use Loop behaviour and use receive and broadcast behaviours based on the label's location to send it the information

      These are both pretty bad workarounds, so does anyone know anything better, or will I just have to wait for hyperPad to add support to object referencing?

      Aidan_FireA Offline
      Aidan_FireA Offline
      Aidan_Fire
      wrote on last edited by
      #2

      @kamdroid I just did some playing around, even looping with broadcast won't work because the object can't receive the message because the loop is too fast for the 2 behaviours (spawn and broadcast) to work together. I wouldn't dynamically spawn buttons and assign them a value based off their position though, I'm not sure how yours works but for mine I'd use an array that's storing all the button values (some sort of marker or ID for what the button is going to do). I'm nearly done with one that would probably spawn 60 buttons per second, I'll give the project link.

      KamdroidK 1 Reply Last reply
      0
      • KamdroidK Kamdroid

        I am wondering if anyone has any good idea on how to dynamically spawn a list of buttons.

        These are the two ideas I have came up with:

        • Use a timer with a slight delay and set an attribute that the label will set to once spawned (pretty slow)

        • Use Loop behaviour and use receive and broadcast behaviours based on the label's location to send it the information

        These are both pretty bad workarounds, so does anyone know anything better, or will I just have to wait for hyperPad to add support to object referencing?

        Aidan_FireA Offline
        Aidan_FireA Offline
        Aidan_Fire
        wrote on last edited by
        #3

        @kamdroid I give up, spawning was too slow and behaviours that I wanted to be activated after the object was spawned (like broadcast message) were happening before the object finished spawning. So yeah, you'll have to make it spawn them slowly.

        1 Reply Last reply
        0
        • KamdroidK Kamdroid

          I am wondering if anyone has any good idea on how to dynamically spawn a list of buttons.

          These are the two ideas I have came up with:

          • Use a timer with a slight delay and set an attribute that the label will set to once spawned (pretty slow)

          • Use Loop behaviour and use receive and broadcast behaviours based on the label's location to send it the information

          These are both pretty bad workarounds, so does anyone know anything better, or will I just have to wait for hyperPad to add support to object referencing?

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

          @kamdroid I don't understand what you mean by dynamically spawning a list of buttons.

          What is dynamic about them? What is changing?

          What is a "list of buttons"?

          If I can understand these things, I think the dynamic system I have, for showing dynamic scores on objects, will work. But I don't think I fully understand what you're wanting to do.

          In this video (below), notice the scores showing up on the hit discs, inside them, they're dynamically generated, and instantly placed (from pre-spawned pool, for speed) at these locations. This can handle dozens of them, all with different scores, as each hit increments the scoring. Hit a disc 1x = 500, 2nd time = 750, 3rd = 1000, etc...

          Similarly, the Hexagons in the background, when rolled over, start at 100 points and go up for each rollover after that. And, again, this is all specific to the objects, and dynamically placed, from a pool. Each hexagon "requests" a score to show upon itself.

          password = spinjump

          KamdroidK 1 Reply Last reply
          1
          • D Deeeds

            @kamdroid I don't understand what you mean by dynamically spawning a list of buttons.

            What is dynamic about them? What is changing?

            What is a "list of buttons"?

            If I can understand these things, I think the dynamic system I have, for showing dynamic scores on objects, will work. But I don't think I fully understand what you're wanting to do.

            In this video (below), notice the scores showing up on the hit discs, inside them, they're dynamically generated, and instantly placed (from pre-spawned pool, for speed) at these locations. This can handle dozens of them, all with different scores, as each hit increments the scoring. Hit a disc 1x = 500, 2nd time = 750, 3rd = 1000, etc...

            Similarly, the Hexagons in the background, when rolled over, start at 100 points and go up for each rollover after that. And, again, this is all specific to the objects, and dynamically placed, from a pool. Each hexagon "requests" a score to show upon itself.

            password = spinjump

            KamdroidK Offline
            KamdroidK Offline
            Kamdroid
            wrote on last edited by
            #5

            @deeeds This is what I mean: 0_1523402596504_6577DE48-EB29-46A2-B9B5-2FE70E5A4CDB.png

            D 1 Reply Last reply
            0
            • Aidan_FireA Aidan_Fire

              @kamdroid I just did some playing around, even looping with broadcast won't work because the object can't receive the message because the loop is too fast for the 2 behaviours (spawn and broadcast) to work together. I wouldn't dynamically spawn buttons and assign them a value based off their position though, I'm not sure how yours works but for mine I'd use an array that's storing all the button values (some sort of marker or ID for what the button is going to do). I'm nearly done with one that would probably spawn 60 buttons per second, I'll give the project link.

              KamdroidK Offline
              KamdroidK Offline
              Kamdroid
              wrote on last edited by
              #6

              @aidan-oxley strange - I use this method for dynamically spawning apps in my new OS sim.

              Aidan_FireA iTap DevelopmentI 2 Replies Last reply
              0
              • KamdroidK Kamdroid

                @aidan-oxley strange - I use this method for dynamically spawning apps in my new OS sim.

                Aidan_FireA Offline
                Aidan_FireA Offline
                Aidan_Fire
                wrote on last edited by
                #7

                @kamdroid Yeah, you need a delay for it, spawn object then wait maybe 0.1s then broadcast a message or something for it's data. Actually, now that I think about it, you could spawn them all at once (using a loop) then once you're sure they have all fully spawned, broadcast a single message with an array for the value containing the data for every button based on it's position. All buttons receive the message and using their position they find the data relevant to itself.

                1 Reply Last reply
                0
                • KamdroidK Kamdroid

                  @deeeds This is what I mean: 0_1523402596504_6577DE48-EB29-46A2-B9B5-2FE70E5A4CDB.png

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

                  @kamdroid

                  Create an example of a button object in the Editor. Sprite image, and the text object required to fill out this button. I use images for button objects and the text because Sprite Sheets and bitmap fonts don't currently work in hyperPad. This means I have a graphic element for a score of 100, 200, 250, 500 etc. You need these images for button1's text, button2's text, etc.

                  You only need one button graphic.

                  You also need a dummy object that's going to represent the eventual locations of your buttons. This dummy object needs a tag that defines it as a dummy object. Duplicate this as many times as you need, and place it in your scene where the buttons will go.

                  When your game starts:

                  have an array get the position of each of these dummy objects, and store their x and y in respective arrays, as it finds them. It will do this in a reliable order, so X and Y won't get confused. But you do need two arrays. Dummy_y_positions and Dummy_x_positions, or something like that.

                  Delete the dummy objects, they're no longer of any use

                  Run a for loop that's the length of the array, and spawn a button object and a text object for each of your buttons, and position them, in this for loop, at 0, 1, 2, 3, 4 etc on the X axis, via their index from their relative array positions (where you're going to get their eventual positions).

                  Now the tricky part.

                  Inside each of the text and button images is code that merges the name you give the buttons with their individual index in the array. use this as a receiver string for a message receive behaviour in each object that blends this text together on spawn.

                  Now you have a reference mechanism between each object at any given position, and an array that lets you call into any specific one of them and tell it to do as you please.

                  And pray that they introduce proper referencing and instancing in the next update()

                  ;)

                  1 Reply Last reply
                  0
                  • KamdroidK Kamdroid

                    @aidan-oxley strange - I use this method for dynamically spawning apps in my new OS sim.

                    iTap DevelopmentI Offline
                    iTap DevelopmentI Offline
                    iTap Development
                    wrote on last edited by
                    #9

                    @kamdroid what data are you wanting to be sent to each button?

                    1 Reply Last reply
                    0
                    • iTap DevelopmentI Offline
                      iTap DevelopmentI Offline
                      iTap Development
                      wrote on last edited by
                      #10

                      And what are the buttons controlling/ triggering?

                      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