How To Move A View Then Trigger An Event

Brian_Provinciano I will have the next tutorial done is a week or so, but until then, I thought I'd post a response to a question for all to benefit.

To move a view from one place to another, then do something when it reaches it's destination, you use the view's setMotion method with the RoomScript's changeState method.


Here's an example:


/******************************************************************************/
(instance public rm001 of Rm
   (method (init)
   ...
   (aMan:
      init()
      setCycle(Walk)
      setMotion(MoveTo 180 150 RoomScript)
   )
   )
)
/******************************************************************************/
(instance aMan of Act
   (properties
      y 170
      x 190
      view 1
   )
)
/******************************************************************************/
(instance RoomScript of Script
   (properties)
   (method (changeState newState)
   = state newState
   (switch (state)
      (case 0
      Print("This is state 0! The room has started!")
      )
      (case 1
      Print("The view has moved to it's first position!")
      (aMan:
         setMotion(MoveTo 150 140 RoomScript)
      )
      )
      (case 2
      Print("The view has moved to it's second position!")
      )
   )
   )
   ...
)
Joe Ohhhhh. That would be like using flags right? Cool Brian. Can't wait till the next tutorial. Keep up the good work!