hyperPad hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    Best way to set up behaviors?

    Scheduled Pinned Locked Moved
    Help and Support
    4
    10
    350
    Loading More Posts
    • 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.
    • iTap DevelopmentI
      iTap Development
      last edited by

      Is there any reason to use one or the other of the two setups in the screen shot?0_1510515851046_87141109-CCA5-4ECC-A0F5-C8EF364638F7.png

      D 1 Reply Last reply Reply Quote 1
      • D
        Deeeds @iTap Development
        last edited by

        @iTap-Development As I understand it, for duration based activities, the example on the left will activate actions based on those durations.

        So if you want to:

        • move up 10 metres during 1 second
          then
        • move down 10 metres during 1 second

        If you use the layout on the right, the object won't appear to move to up as that behaviour will be overridden by the immediate call of the move to go down.

        iTap DevelopmentI 1 Reply Last reply Reply Quote 0
        • iTap DevelopmentI
          iTap Development @Deeeds
          last edited by

          @Deeeds oh I didn’t even think about that, but I tested and that is the case. With the exception of the interrupt movement toggle being on on the second behavior, in which case the second behavior will run. But the first one won’t run regardless of the toggle being on or off on either.

          Aidan_FireA 1 Reply Last reply Reply Quote 0
          • Aidan_FireA
            Aidan_Fire @iTap Development
            last edited by

            @iTap-Development I think if you use the one on the right it will all happen faster.

            Jack8680J 1 Reply Last reply Reply Quote 0
            • Jack8680J
              Jack8680 @Aidan_Fire
              last edited by

              @Aidan-Oxley why? They look exactly the same?

              D 1 Reply Last reply Reply Quote 0
              • D
                Deeeds @Jack8680
                last edited by Deeeds

                @Jack8680 Theoretically, the one on the right should be able to initiate and issue a bunch of math operations before the results come back. But that depends a lot on what's going on inside cocos2D in terms of managing this sort of rapid fire activity, and how hyperPad lads have done things, too, how iOS plays with it, how many cores you have, etc etc...

                If you were doing this through arrays, and trying to operate on a bunch of things, I'd use the technique on the right just in case you get speed advantages, because that's definitely where you're going to get them.

                The one on the left is going to wait for the result from each math operation before continuing... I think. Probably. That would be the safest way it could be programmed, since subsequent operations for the one on the left might be relying on results further up the branch to operate on.

                iTap DevelopmentI Jack8680J 2 Replies Last reply Reply Quote 0
                • iTap DevelopmentI
                  iTap Development @Deeeds
                  last edited by

                  @Deeeds why would you get speed advantages on the right?

                  1 Reply Last reply Reply Quote 0
                  • Jack8680J
                    Jack8680 @Deeeds
                    last edited by

                    @Deeeds The behaviours on the right can still use the outputs from previous behaviours though, and they will activate in order. For example replacing 'add values4' with a loop that runs loads of times, the loop will finish before 'divide values2' (next to it) will activate.

                    I set up a project to test which runs faster and they seem to be around the same. For a moment the left one seemed slightly faster, but switching the behaviours in the two objects around reversed the result, so it's impossible to tell exactly which is faster, they were both within a few percent of each other, I'm guessing something in the engine itself affects it slightly.

                    I'm assuming it compiles the behaviours into 1 dimensional code, and that the two will be identical. When a behaviour has a duration the left one waits for it to finish, while the right one probably performs a step each frame, while still continuing with the behaviours next to it. For multiply, add, divide though, there's no noticeable difference.

                    iTap DevelopmentI 1 Reply Last reply Reply Quote 0
                    • iTap DevelopmentI
                      iTap Development @Jack8680
                      last edited by

                      @Jack8680 so if I added another add values to the right one, would the divide run before the second add values?

                      1 Reply Last reply Reply Quote 0
                      • iTap DevelopmentI
                        iTap Development
                        last edited by iTap Development

                        @Murtaza or @Hamed what way would you recommend?

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post