Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
VideoCodecCheck
write/append to text file
Maeda @ Media
Making Multiple Animated Buttons
StarMenu Xtra
Loungin.net
Bitmap text
Merge sort and Binary Search using Lingo
Emulator
Shockwave Stand Alone Installer
 

 

 

Behavior Sin Path Movement

Added on 9/21/1999

 

Compatibilities:
behavior D6_5 D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: MatthijsKlinkert (website)

Sin Path Movement

--1999 Matthijs Klinkert, buro Zicht, Delft, The Netherlands
--Startposition X: enter the X-startposition on the stage in pixels.
--Startposition Y: enter the Y-startposition on the stage in pixels.
--Speed: enter the speed of movement 1 = slow, 10 = fast.
--Amplitude: enter the amplitude of the funtion in pixels.
--Period: enter the period of the function in pixels.
--Which direction: choose left or right.
property pMyXpos, pMyYpos, pSpeed, pPeriod, pAmplitude, pMyDirection

on beginSprite me
  
  set the locH of sprite the spriteNum of me = pMyXpos
  set the locV of sprite the spriteNum of me = pMyYpos
  add(the actorList, me)
  
end


on endSprite me
  
  deleteOne(the actorList,me)
  
end

--

on stepFrame me
  
  if pMyDirection = "Right" then
    set pMyXpos = pMyXpos + pSpeed
  else
    set pMyXpos = pMyXpos - pSpeed
  end if
  
  set stageWidth = the stageRight - the stageLeft
  
  if pMyDirection = "Right" then
    if pMyXpos > stageWidth then
      set pMyXpos = 0
    end if
  else
    if pMyXpos < 0 then
      set pMyXpos = stageWidth
    end if
  end if
  
  set the locH of sprite (the spriteNum of me) = pMyXpos
  set x = the locH of sprite the spriteNum of me
  set the locV of sprite (the spriteNum of me) =
pMyYpos + integer(float(pAmplitude*(sin((float(pMyXpos)/float(pPeriod))*PI))))
  set y = the locV of sprite the spriteNum of me
  updateStage
  
end

on getPropertyDescriptionList me  
  set propList = [#pMyXpos: [#comment: "Startposition X (in pixels)", #format: #integer,
#default: 0], #pMyYpos: [#comment: "Startposition Y (in pixels)", #format: #integer,
#default: 0], #pSpeed: [#comment: "Speed", #range: [1,2,3,4,5,6,7,8,9,10], #format: #integer,
#default: 5], #pAmplitude: [#comment: "Aplitude", #format: #integer, #default: 30],
#pPeriod: [#comment: "Period", #format: #integer, #default: 50],
#pMyDirection: [#comment:"Which direction?", #range: ["Left", "Right"], #format: #string,
#default: "Right"]]
  return propList  
end

on getBehaviorDescription me  
  return "1999 Matthijs Klinkert, buro Zicht, Delft, The Netherlands" && RETURN && RETURN &
"• Startposition X: enter the X-startposition on the stage in pixels."
&& RETURN &
"• Startposition Y: enter the Y-startposition on the stage in pixels." && RETURN &
"• Speed: enter the speed of movement 1 = slow, 10 = fast." && RETURN &
"• Amplitude: enter the amplitude of the funtion in pixels." && RETURN &
"• Period: enter the period of the function in pixels." && RETURN &
"• Which direction: choose left or right."
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail