Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
detecting hard disk
Hold on a frame till Flash finishes playing
Animate Image Sequence
Store and restore Director objects as an XML string
Show Recordset's Current Record
Spawn
Shockwave Remote Faq
Check QuickTime Version
Imaging Lingo Basics
Macromedia Licensing
MediaMacros Xtras Mall
 

 

 

Behavior Simple projectile with gravity

Added on 12/18/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

Rating:

Author: BarrySwan (website)

Allows a member to scroll over the movie, by defined parametres...

--Description
--------
--Drop onto a sprite to give it simple movement based on a firing angle,
--direction, and speed, as well as controlling gravity.


--Code
-------
property pSpeed
property pAngle, pDirection
property pX, pY
property pDX, pDY
property pGravity
property pS

on beginSprite me

  -- Initialise variables
  pS = sprite(me.spriteNum)
  pX = float(pS.locH)
  pY = float(pS.locV)

  -- Calculate movement vector
  pDX = sin(pAngle / 180.0 * pi()) * pSpeed
  pDY = -cos(pAngle / 180.0 * pi()) * pSpeed

  -- Flip X direction if wanting to move left
  if pDirection = #left then pDX = -pDX

end

on prepareFrame me

  -- Update variables
  pX = pX + pDX
  pY = pY + pDY
  pDY = pDY + pGravity

  -- Update sprite position
  pS.loc = point(integer(pX), integer(pY))

end

on getPropertyDescriptionList me
  -- Set up data
  tlData = [:]
  tlData[#pSpeed] = [#comment: "What speed? (In pixels per update)", #format: #float, #default: 10.0]
  tlData[#pAngle] = [#comment: "What angle? (0 = horizontal, 90 = vertically up)", #format: #float, #default: 45.0]
  tlData[#pDirection] = [#comment: "Fire left or right?", #format: #symbol, #default: #right, #range: [#left, #right]]
  tlData[#pGravity] = [#comment: "Gravity strength? (In pixels per update)", #format: #float, #default: 0.5]
  -- Return data
  return tlData
end

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail