8 Replies Latest reply on May 12, 2007 8:47 AM by Charles Parcell

    Random prb

    uneus
      I have a little game where some bolls are coming and going in different positions. My prb is that when I put this script on another sprite it works just first run. When movie loops it´s just the first sprite which works with the script and the second is unvisible.
        • 1. Re: Random prb
          Charles Parcell Level 1
          There is only one timer in Director. So, all the starting and restarting of the timer is most likely messing up things.

          Also, make sure you don't have additional scripts attached to the sprites that alter things.
          • 2. Re: Random prb
            bjanun
            Thx for helping. Do you have any suggestions "how to" make a random on different sprites?
            • 3. Re: Random prb
              Charles Parcell Level 1
              Indeed I do.

              In place of where you "startTimer" you should capture the system time.

              property pTimeCapture
              -- Captures time in seconds
              pTimeCapture = _system.milliseconds/1000

              You will have to alter your pAppearAgain set code. Something like this...

              pAppearAgain = (timeCapture + random(5)) * 50

              • 4. Re: Random prb
                bjanun Level 1
                Thank you very much for all help. Im going to try that at once.
                • 5. Re: Random prb
                  Level 7
                  On Wed, 09 May 2007 15:51:24 +0200, uneus <webforumsuser@macromedia.com>=
                  =

                  wrote:

                  > I have a little game where some bolls are coming and going in differen=
                  t
                  > positions. My prb is that when I put this script on another sprite it =
                  =

                  > works
                  > just first run. When movie loops it?s just the first sprite which work=
                  s =

                  > with
                  > the script and the second is unvisible.
                  >
                  > property pPositioning, pAppearAgain, pStayStill
                  >
                  > on beginSprite me
                  > startTimer
                  > sprite(me.spriteNum).visible =3D FALSE
                  > pPositioning =3D 0
                  > pAppearAgain =3D (1+ random(5)) * 50
                  > end
                  >
                  > on exitFrame me
                  > if pAppearAgain < the timer then
                  > if pPositioning =3D 0 then
                  > sprite(me.spriteNum).locH =3D random(436) + 38
                  > sprite(me.spriteNum).locV =3D random(264) + 39
                  > sprite(me.spriteNum).visible =3D TRUE
                  > pPositioning =3D 1
                  > startTimer
                  > pStayStill =3D random(8) * 1
                  > end if
                  > end if
                  > if pStayStill < the timer then
                  > if pPositioning =3D 1 then
                  > sprite(me.spriteNum).visible =3D FALSE
                  > pPositioning =3D 0
                  > startTimer
                  > pAppearAgain =3D (1+ random(5)) * 10
                  > end if
                  > end if
                  >
                  > end
                  >

                  the timer =3D 0

                  -- =

                  GoGs
                  • 6. Re: Random prb
                    uneus Level 1
                    I´ve tried that in several ways but can´t get it running. I added the 3D to "property" but I get errormessages all the time like: Expected end of statement
                    sprite(me.spriteNum).visible =3D FALSE. I don´t now what to do because if I change this to only false (no name before) I get the next line with error message and so on.
                    • 7. Re: Random prb
                      Chunick Level 3
                      uneus,

                      if you look a bit closer at the pattern and the poster you will notice that =3D is some sort of formatting screw up because the poster, GoGs is posting from a newsgroup. =3D should be =
                      • 8. Re: Random prb
                        Charles Parcell Level 1
                        Yes, basically his suggestion was to set timer to zero

                        the timer = 0

                        But that is what startTimer does. So, I don't think you are going to get anywhere with that.