2 Replies Latest reply on May 19, 2006 9:46 AM by Mazuho

    StepFrame

    Mazuho
      I'm feeling very dumb right now. I have tried oh so many exampled of stepframe, but I still can't implement it in my own code. My guess is that it's because I'm not a seasoned programmer that I don't really get the actorlist thing. I'm having several movie scripts that control my 3d member, and when the player shoots with his/her tank I want a bullet soaring through the air and eventually hitting the ground. And this is were stepframe comes into action. I have one script which contains the info for how the bullet should travel, and Í want stepframe to call this every frame. Here is how I have put up the code.

      on shoot me
      (the actorlist).append me
      end

      on stepframe
      trajectory
      end

      This is in one movie script. The trajectory script is in another movie script. I am not very good at lingo, so I have propably misunderstood how I am supposed to call scripts in other movie scripts. Well, thanks for any help!
        • 1. Re: StepFrame
          James Newton, ACP Level 3
          The code that you show looks correct... but you say that it is in a Movie Script. The 'me' parameter that you are using will be <Void> if 'on shoot me' is in a Movie Script: placing VOID on the actorList will have no effect.

          You could change your code to this:

          -- Movie Script

          on shoot()
          vBullet = script("Bullet").new()
          (the actorList).append(vBullet)
          end shoot


          -- Parent Script named "Bullet" --

          on new(me)
          return me
          end new


          on stepFrame(me)
          me.trajectory()
          end stepFrame


          on trajectory(me)
          -- This is where all your calculations go
          end trajectory


          This is just the bare bones of a Parent script. You will probably need to have a reference to the 3D member, and to store the value of the milliseconds when the bullet was fired. You can use properties for these. You can set the values for these properties in the 'on new()' handler:

          -- Parent Script named "Bullet|" --

          property p3DMember
          property pStartTime

          on new(me)
          p3DMember = member("3D world") -- or whatever your member's name is
          pStartTime = the milliseconds

          return me
          end new


          If you are used to using globals to hold permanent values, then you will understand that properties can hold permanent values too. But property values can only be accessed from inside the script instance itself. They are not 'global' in scope; they are owned by the Bullet instance. This means that you can create several Bullet instance, each with its own value of pStartTime.
          • 2. Re: StepFrame
            Mazuho Level 1
            Thank you, that cleared up my mind.